I am trying to dynamically create some sort control cards but can't seem to get it to work.
I have coded a couple of different ways but I am stumped - I thought I could concatenate with the pipes?
JOBNAME is equal to - JOB1
PUT @3 'INCLUDE COND=(21,8,CH,EQ,C'||JOBNAME||',OR,';
I am trying to end up with:
INCLUDE COND=(21,8,CH,EQ,C'JOB1',OR,
Any recommendations is greatly appreciated.
Hi,
You can try this to get the desired output.
data _null_;
JOBNAME='JOB1';
put @3 'INCLUDE COND=(21,8,CH,EQ,C' " ' " JOBNAME : " ' " ',OR,';
run;
Thanks it works fine for what I need but for some reason it puts an extra space after the jobname?
The sort control cards still work ok with it, but I wasn't sure why?
PUT @3 'INCLUDE COND=(21,8,CH,EQ,C'"'"JOBNAME"'"',OR,';
Output =
INCLUDE COND=(21,8,CH,EQ,C'ABCJOB01 ',OR,
Try this, will remove extra space after the jobname.
data _null_;
JOBNAME='JOB1';
put @3 'INCLUDE COND=(21,8,CH,EQ,C'"'" JOBNAME $4."'" ',OR,';
run;
I still get the space but now I get a SAS warning:
20 PUT @3 'INCLUDE COND=(21,8,CH,EQ,C'"'"JOBNAME"'"',OR,';
___
49
NOTE 49-169: The meaning of an identifier after a quoted string might change in
between a quoted string and the succeeding identifier is recommende
I am not sure but I am getting the right ouput with no message using the following
put @3 'INCLUDE COND=(21,8,CH,EQ,C'"'" JOBNAME $4."'" ',OR,';
Sometimes the jobname has 7 characters and I guess because of the $8. format it leaves a blank?
SORT FIELDS=(1,8,CH,A)
INREC FIELDS=(1:21,8,9:40,44,28X)
INCLUDE COND=(21,8,CH,EQ,C'XXXXXXUP',OR,
21,8,CH,EQ,C'XXXXXX7 ',OR,
Yes, that is right.
Thanks for your great support, it truly is appreciated. It is because of people like you that make SAS a great tool to tackle all kinds of situations!
I'm not sure what a sort control card is and what are you trying to do, can you provide more info?
The host sort interface will generate those control cards automatically when sorting sas datasets.
Some host sort interfaces are supporting direct it (syncsort) to sas decreasing the im resource usage.
As all is standard present why would you try to generate those controlcards
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.