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!
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
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
Ah.. simple change. Thank you very much!!
Good... I used to do it with a data step, using retain, call symput, catx(..)..This one looks neat.
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
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.
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.