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

Hello,

I want to take the value of a entire single column and store it as a macro variable. I tried using :into clause and it is giving me just the first row value but if i use separated by ',' it works fine. The problem with that is  I don't want the macro variable with commas.

Data col1;

input serial_no $3.;

cards;

100

120

130

140

;

Run;

Proc Sql noprint;

Select serial_no into :sno

from col1

;

Quit;

%Put %sno;

The above gives me an output of 100 but i want it as 100 110 650 435(no commas in between).

Thanks in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Hi, you can separate by any delimiter of your choice, in this case you want blank.

Proc Sql noprint;

Select serial_no into :sno separated by ' '

from col1

;

Quit;

%Put &sno;

Haikuo

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

Hi, you can separate by any delimiter of your choice, in this case you want blank.

Proc Sql noprint;

Select serial_no into :sno separated by ' '

from col1

;

Quit;

%Put &sno;

Haikuo

vicky07
Quartz | Level 8

Ah.. simple changeSmiley Happy. Thank you very much!!

flysnow
Calcite | Level 5

Good...  I used to do it with a data step, using retain, call symput, catx(..)..This one looks neat.

pavan1
Obsidian | Level 7

Hello,

 

how to store column values with strings as macro variable?

 

Ex:

data dts;

           length l_dset $15 ttl $100;

           infile datalines delimiter='|';

           input l_dset $ ttl $;

                   datalines;

LIS002|Illegible text

LIS003|Duplicate AEs

LIS004|Overlapping AEs

LIS005|Duplicate Conmeds

LIS015|Abacavir HSR and AE consistency

LIS021|Compare age at screening

LIS023|Laboratory date sample not in Chronolical order

LIS024|Laboratory sample time is not the same for other samples collected at same visit

LIS025|Multiple visit date

LIS026|Multiple sample date

LIS027|Duplicate Samples on same sample date

LIS028|LowerCase Units

;

run;

 

I want only the ttl column from the dataset dts to be stored in macro variable and fetch those for later use.

 

Please help me on this. i have been struggling with this.

 

thanks,

Pavan.Ch

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 28017 views
  • 2 likes
  • 4 in conversation