1
votes

Hi in SAS I'm using these statements:

 %LET xls=Selectie_&datum._&hhmm.;
 PROC EXPORT DATA=work.selectie OUTFILE="&pad.\&xls..xlsx"
 DBMS=XLSX
 REPLACE
    ;
  newfile=yes;
  quit;

the file has been created ok: NOTE: "\SRTZZAPP0274\SASData\NNB\MFT_Output\Banksparen\Selectie_20161028_1118.xlsx" file was successfully created.

so fat so good. But when I want to use this macrovar I cannot get this value. !NNBankdata is an environment var.

 %put &pad;
 !NNBankData\MFT_Output\Banksparen

so how is it possible to revolve !NNBankData also like it is working in proc export?

pad has been created to read a flat file with this value: NNBankData\MFT_Output\Banksparen and put this in a macro var: CALL SYMPUTX('pad',TRIM(pad),'G');

2

2 Answers

2
votes

If the first character of a filename reference is an exclamation mark (!) then SAS will attempt to resolve the first item as an environment variable.

As user 667489 mentions, the following should give you your path:

%put %sysget(pad);

An example of this in action:

data _null_;
  file "!temp\test.txt";
  put 'test';
run;

More information can be found in this SGF paper

0
votes

You should use the %sysget function to retrieve environment variables.