BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jumboshrimps
Quartz | Level 8

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@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;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

What dataset do you want to create? What do you want to call the variable?

data want;
  working_dir = getoption('work');
run;
Reeza
Super User

@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;

Jumboshrimps
Quartz | Level 8

Captain Obvious sez "Thanx", 'cause that was, well obvious.........

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 862 views
  • 1 like
  • 3 in conversation