Want to create a dataset containing one variable - the SAS temporary working directory on a
RedHat 7.7 (Maipo) server. Code below works fine, until I try to write the (looooong) working
directory string to a temporary dataset.
CODE:
proc options option = work; <<<gets temporary SAS work directory
run;
%put %sysfunc(getoption(work));
%let tmpSASwrk = %sysfunc(getoption(work));
%put &tmpSASwrk;
data working; <<<create a SAS data set "Working" with just 1 variable - temp work directory
call symput("workdir",&tmpSASwrk);
run;
Although the working directory is correctly identified, I get the following error:
"/saswork/SAS_work28AD0000FF4A_someplace.over.therainwbow.com" <<<correct working directory
22 780
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,
a datetime constant, a missing value, INPUT, PUT.
ERROR 780-185: Invalid object or method name.
How can I save the current (temporary) working directory string to a dataset with one variable?
@Jumboshrimps wrote:
data working; <<<create a SAS data set "Working" with just 1 variable - temp work directory
call symput("workdir",&tmpSASwrk);
run;
That part is incorrect, that's creating a macro variable with the work directory, equivalent to tmpSASwrk so its not doing what you think it's doing. This will, but make sure the length of the variable is long enough.
data working;
length workdir $300.;
workdir = "&tmpSASwrk";
run;
What dataset do you want to create? What do you want to call the variable?
data want;
working_dir = getoption('work');
run;
@Jumboshrimps wrote:
data working; <<<create a SAS data set "Working" with just 1 variable - temp work directory
call symput("workdir",&tmpSASwrk);
run;
That part is incorrect, that's creating a macro variable with the work directory, equivalent to tmpSASwrk so its not doing what you think it's doing. This will, but make sure the length of the variable is long enough.
data working;
length workdir $300.;
workdir = "&tmpSASwrk";
run;
Captain Obvious sez "Thanx", 'cause that was, well obvious.........
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.