Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: zipsave and zipuse


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: zipsave and zipuse
Date   Wed, 3 May 2006 10:59:23 +0100

The FAQ asks 

"Say what command(s) you are using. If they are not part of 
official Stata, say where they come from: the STB/SJ, SSC, or 
other archives."

In this case, -zipsave-, -zipuse- come from SSC. As such, 
the code is clearly visible, even without installing: 

. ssc type zipsave.ado

pr de zipsave
* Save as zipped dataset
*! 0.1 HS, Jan 6, 2006
version 8.0
syntax [anything(name=file)] [, replace *]
qui {

  if `"`file'"' == "" {
    local file = "$S_FN"
    if `"`file'"' == "" {
      di in red "invalid file specification"
      exit
    }
  }

  * Only check for punctuation in filename, not in path
  _getfilename "`file'"
  
  if index(r(filename), ".") == 0 {
    local file = "`file'" + ".dta.zip"
  }
  
  if "`replace'" == "" {
    confirm new file `file'
  }
  else {
    capture confirm file `file'
    if _rc == 0 {
      !rm `file'
    }
    else {
      di in green "(note: file `file' not found)"
    }
  }
  
  tempfile tmpdat
  if "`options'" == "" {
    sa `tmpdat'
  }
  else {
    sa `tmpdat', `options'
  }
  
  shell zip -j - `tmpdat' > `file'
*  shell cat `tmpdat' | zip > `file'
  global S_FN = "`file'"

  noi di in green "data compressed with zip and saved in file `file'"
  
}
end

You don't have to be a programmer to see where and how
zip is invoked. So, either set up your zip program 
so this will work, or copy, rename and modify the 
Stata program so that it calls your zip program. 
(You are now the program author and responsible
for everything!) 

Nick 
[email protected] 

Rajesh Tharyan
 
> Could someone give me any advice on how to run this command 
> on stata 8.2
> running on win xp. I have downloaded the zip and unzip files from the
> website mentioned in the help files. When I issue the command 
> it saves the
> current file as a zip file but the file in empty.
> 
> Command issued:  zipsave c:\a.dta
> 
> Stata returns:  data compressed with zip and saved in file c:\a.dta
> 
> To check I issued the command shell which zip , that returned 
> nothing. Which
> probably means I haven't configured it correctly. When I use 
> zipuse I get
> the following message
> 
> 
> Command issued :  zipuse c:\a.dta
> 
> Stata returns:  file 
> C:\DOCUME~1\Rajesh\LOCALS~1\Temp\ST_00000002.tmp not
> Stata format
> 
> Also, The latest version (version 10)  of winzip now includes 
> a command line
> addon. I was wondering if the zipsave and zipuse commands 
> could be used with
> winzip

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index