BookmarkSubscribeRSS Feed
atul_desh
Quartz | Level 8

/*SAS Job name test.sas*/

libname srcf "$1";

data srcf.$2;

input a;

datalines;

1

2

;

run;

I want to run as below : 

/*value of $1 = /mdir/subdir/*/

/*value of $2 = test_par*/

Unix command as below : 

sasgsub -gridwait -gridsubmitpgm test.sas /mdir/subdir/1 test_par

4 REPLIES 4
Kurt_Bremser
Super User

$1, $2 and so on are UNIX environment variables that a UNIX shell parses from the commandline with which a shell script was invoked.

To get the value of a UNIX environment variable, use the sysget() data step or %sysget() macro function.

atul_desh
Quartz | Level 8

command : 

 

sasgsub -gridwait -gridsubmitpgm /path1/test.sas -gridsasopts "(-sysparm 'dest_path/fol1 testds')"

 

test.sas : 

 

%let path=%scan(sysparm(),1,' ');
%let ds=%scan(sysparm(),2,' ');
libname pt "&path";
data pt.&ds;
input a;
datalines;
1
2
;
run;

 

path & ds are not resolving !!

Kurt_Bremser
Super User

When you do this:

%let path=%scan(sysparm(),1,' ');

%scan scans the TEXT(!) sysparm() for the first word, and delivers

sysparm()

so &path will always just render sysparm(). Also keep in mind that the macro preprocessor only knows the data type text, and therefore quotes around strings are not needed and cause harm.

Try this instead:

data _null_;
length path $100;
path = scan(sysparm(),1,' ');
call symput('path',trim(path));
run;
atul_desh
Quartz | Level 8

It worked : 

 

%let path=%scan(&sysparm,1,' ');
%let ds=%scan(&sysparm,2,' ');
libname pt "&path";
data pt.&ds;
input a;
datalines;
1
2
;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 937 views
  • 0 likes
  • 2 in conversation