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

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
Obsidian | Level 7

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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