BookmarkSubscribeRSS Feed
srosenfe
Fluorite | Level 6

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.

10 REPLIES 10
stat_sas
Ammonite | Level 13

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;

srosenfe
Fluorite | Level 6


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,

stat_sas
Ammonite | Level 13


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;

srosenfe
Fluorite | Level 6

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

stat_sas
Ammonite | Level 13

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,';

srosenfe
Fluorite | Level 6

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,

stat_sas
Ammonite | Level 13

Yes, that is right.

srosenfe
Fluorite | Level 6

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!

Reeza
Super User

I'm not sure what a sort control card is and what are you trying to do, can you provide more info?

jakarman
Barite | Level 11

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

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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