"Unfortunately, the target directory must be that narly SAS temp WORK directory."
That's exactly what @Tom 's code does. You can just use it as you've requested: SET %gunzip(&lib..&dataset);
The parameter Target in the macro definition has a default of WORK so you don't need to define it when calling the macro. It just gives you the option to also use another library path if you ever need to.
%macro gunzip(dsname,target=work);
If you execute below code you'll see that for WORK when using pathname() you'll get exactly the same result than when using getoption(). Execute below code in your environment and compare the results.
%let target=work;
%put %sysfunc(pathname(&target));
%put %sysfunc(getoption(&target));
Replacing the remaining two "x" in the macro with %sysexec, causes the macro to run correctly.
I put a sleep(50000) in the middle of the macro to cd into the temp directory and verify the dataset, is in fact, there
and correctly named.
All good!!!
After the successful completion of the macro, I'm getting
MLOGIC(C14_UZIP_V3): Ending execution.
ERROR: There is not a default input data set (_LAST_ is _NULL_).
73 run;
I'm guessing the original SET statement cannot read in the dataset in SAS temp WORK?
All this started with a SET %gunzipmacro(&lib.&dataset);
To get that message you will need to run a SET statement without any dataset name.
set ;
So that means your current macro is not only no longer generating the X command. It is also NOT generating the name that the SET command could use to find the dataset you unzipped.
Did you not read the example macros that we posted for you?
You need to create the dataset name. Study my macro closely, and you'll see when it does that.
Again, thank you.
Are you referring to:
"%let return=&target..&memname;"?
Would that line return the name of the just unpacked dataset in the temp SAS WORK directory to the
calling SET statement from the original program?
I incorporated the %sysexec changes, and all is good.
@Jumboshrimps wrote:
Again, thank you.
Are you referring to:
"%let return=&target..&memname;"?
Would that line return the name of the just unpacked dataset in the temp SAS WORK directory to the
calling SET statement from the original program?
This does not create code, it only stores a value into a macro variable. The "create code" part happens in line 6 of this:
%macro gzip_on_the_fly(filename,libname);
%local targetpath dsfilename;
%let targetpath=%sysfunc(pathname(&libname.));
%let dsfilename=%scan(%scan(&filename.,-1,/),1,.).sas7bdat;
%sysexec gzip -dc &filename. > &targetpath./&dsfilename.;
&libname..%scan(&dsfilename.,1,.)
%mend;
@Jumboshrimps wrote:
Again, thank you.
Are you referring to:
"%let return=&target..&memname;"?
Would that line return the name of the just unpacked dataset in the temp SAS WORK directory to the
calling SET statement from the original program?
I incorporated the %sysexec changes, and all is good.
NO. That is macro statement that is setting the value of a macro variable named RETURN. It will not emit any code that will be passed onto SAS to execute.
If you look later in that macro you will that it also includes this line:
&return
That is evaluating the value of the RETURN macro. And since it is NOT part of any macro language statement the value will be sent be the macro processor onto SAS to evaluate. So that is the place where the name of the dataset to use the SET statement (or where ever you are calling the macro) is being sent from the macro back to SAS.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: