Generate sort control cards

Reply
Contributor
Posts: 23

Generate sort control cards

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.

Trusted Advisor
Posts: 1,204

Re: Generate sort control cards

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;

Contributor
Posts: 23

Re: Generate sort control cards


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,

Trusted Advisor
Posts: 1,204

Re: Generate sort control cards


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;

Contributor
Posts: 23

Re: Generate sort control cards

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

Trusted Advisor
Posts: 1,204

Re: Generate sort control cards

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

Contributor
Posts: 23

Re: Generate sort control cards

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,

Trusted Advisor
Posts: 1,204

Re: Generate sort control cards

Yes, that is right.

Contributor
Posts: 23

Re: Generate sort control cards

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!

Super User
Posts: 17,851

Re: Generate sort control cards

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

Valued Guide
Posts: 3,208

Re: Generate sort control cards

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 --<-----
Ask a Question
Discussion stats
  • 10 replies
  • 371 views
  • 0 likes
  • 4 in conversation