I have an input in excel like this
| Symbol |
| KO:SGL |
| KO:KAW |
| KO:HDR |
| KO:NHN |
| KO:CLZ |
| KO:HYI |
| KO:HAC |
| KO:AMN |
| KO:SFC |
| KO:PIS |
| KO:KAM |
| KO:SHB |
I want to have an output like this.
Symbol
KO:SGL, KO:KAW, KO:HDR, KO:NHN, KO:CLZ, KO:HYI, KO:HAC, KO:AMN, KO:SFC, KO:PIS, KO:KAM, KO:SHB
Do you know any way to do so?
Thank you,
Depends on wha t you mean by output. You can easily write that to the log or a flat file.
libname myxls xlsx 'sample.xlsx';
data _null_;
set myxls.sheet1 ;
file log dsd ;
put symbol @ ;
run;
Or to a macro variable.
proc sql noprint;
select symbol into :mylist separated by ','
from myxls.sheet1
;
quit;
Or even a trival one observation dataset.
data want ;
length symbols $500 ;
set myxls.sheet1 end=eof;
symbols=catx(',',symbols,symbol);
if eof then output;
retain symbols;
keep symbols;
run;
Depends on wha t you mean by output. You can easily write that to the log or a flat file.
libname myxls xlsx 'sample.xlsx';
data _null_;
set myxls.sheet1 ;
file log dsd ;
put symbol @ ;
run;
Or to a macro variable.
proc sql noprint;
select symbol into :mylist separated by ','
from myxls.sheet1
;
quit;
Or even a trival one observation dataset.
data want ;
length symbols $500 ;
set myxls.sheet1 end=eof;
symbols=catx(',',symbols,symbol);
if eof then output;
retain symbols;
keep symbols;
run;
Hi Cynthia.
Thank you for your sugguestion,
Best,
Hi Tom,
Thank you so much for your detailed response !!!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.