10-29-2014 11:25 AM
Hello everyone. Does anyone know if there is an option in SAS to NOT open the command line dos shell when running an X command, or a %sysexec command?
For example, say I wanted to un-zip 100 folders, and each one took ~5 minutes of un-zip time (due to size of data). It would be impossible to run this program in SAS on a computer, and still type on that computer, because every time the command line DOS Shell opens your typing is moved to that prompt location.
This basically implies you should never run these programs on a computer you are actively using... Which I understand and I can just run it on a different computer, but I was curious if there was an option to avoid this.
An example of the code I am trying to run is
%sysexec "c:\Program Files\7-zip\7z.exe" x "c:\drive\ABC.zip" -O"c:\drive\Newfolder" -y;
10-29-2014 11:41 AM
I "always" use INFILE PIPE FILEVAR=COMMAND for execution of OS commands, no DOS box is just one advantage.
Sometime I like SYSTASK COMMAND but I can't remember if it flashes a DOS box or not. I don't think so.
10-29-2014 11:44 AM
IMO I am not fond of running commands out to system from SAS, so the way I would go about it is to create a batch file with the unzips and run that, hence leaving SAS free to do other things. For example: http://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory
10-29-2014 06:33 PM
Thanks for the noxwait option, but unfortunately this code loops over 10,000 files and each takes ~1 second so basically every time I try to work on the computer I lose control every 1 second, and then gain it back for a milisecond and then lose it, etc.. So in this case that doesn't help much unfortunately. Thanks for the advice tho!
This is actually a step within a much much bigger sas ETL program that I wrote. So I can't have it happen until other steps occur, and then many many other steps need to happen after it. Because of this I am not sure if your solution works to be honest... If I am mid-understanding please let me know.
@data_null_; can you explain what your example is using an actual example of say "opening the notepad" application? I am not sure exactly how I would use what you are saying, but will try to do some more research.
10-29-2014 07:01 PM
Using your SYSEXEC as an example it goes like this. I can't test this I'm not using windows but it does the same thing as SYSEXEC in that it executes the command and sends any stdout to the program as INFILE. If there is not any stdout that's OK it still executes. You can execute more than one COMMAND by looping, reading from SET, etc. Experiment with this and see what you think.
10-29-2014 07:03 PM
I"m struggling to get the systask syntax correct. Can anyone re-write this %sysexec command using systask? it doesn't seem to work no matter how I try the quoting...
%sysexec "c:\Program Files\7-zip\7z.exe" x "I:\Projects\Brandon\zip test\TestZip.zip" -O"I:\Projects\Brandon\zip test\zip test output" -y;
Since only parts of the line are quoted I am curious as to how to put this into the systask command call
10-29-2014 07:18 PM
try single quotes. or quote function %sysfunc(quote("c:\Program Files\7-zip\7z.exe" x "I:\Projects\Brandon\zip test\TestZip.zip" -O"I:\Projects\Brandon\zip test\zip test output" -y))
10-30-2014 04:58 AM
Unfortunately, as far as I am aware currently the ODS Package only supports creating ZIPs, not unpacking them. Pkware has only been around since 1986, so we have to give them some time to catch up :smileysilly:
In response to what I was talking about above, it depends on your setup however I am talking about removing the unpacking part from your ETL, and having the unpacking part done directly on the OS. So (I assume everything here):
You get lots of files sent to you and save them in c:\temp overwriting all the ones currently there as you are using version control.
You then run a batch program which is a text file, with .bat, and is located in c:\temp along with pkunzip.exe.
This runs over each file in c:\temp unzipping every .zip file into a subfolder \output.
You then have an ETL job which runs later on and looks at the unpacked data in c:\temp\output
So the point being SAS does not do any unpacking, only utilizes the unpacked data.
10-30-2014 10:31 AM
Unfortunately no. The code runs, it produces the log, but nothing happens.
I'm actually not sure if the command is just not passing correctly, or not working once passed, etc.. Sorry if I didn't make that clear enough.
10-30-2014 09:43 AM
Truthfully I'm just not a fan of the .bat file methodology, because you are now running two independent programs that are not linked. I would have to first run the .bat file, and then call the sas program... I could probably call the sas program from the .bat file, but now I also have to learn how to script the program already written into a .bat file.
If this is the only way I understand and that's probably what I will end up doing, I am just curious if there is a 'better' way, if that makes sense.