data in;
infile datalines dlm='09'x;
input id 1 num 3-4;
datalines;
2 12
3 45
3 74
5 33
5 12
5 15
;
run;
I want output
| ID | Num |
| 2 | 12 |
| 3 | 45,74 |
| 5 | 33,12,15 |
iAh, sorry. Missed a statement. There u go 🙂
data in;
infile datalines dlm='09'x;
input id 1 num 3-4;
datalines;
2 12
3 45
3 74
5 33
5 12
5 15
;
data want(drop=oldnum);
set in(rename=(num=oldnum));
length num $100;
by id;
num=catx(',', num, oldnum);
if first.id then num=oldnum;
if last.id then output;
retain num;
run;
proc print data=want;
run;
data in;
infile datalines dlm='09'x;
input id 1 num 3-4;
datalines;
2 12
3 45
3 74
5 33
5 12
5 15
;
data want(drop=oldnum);
set in(rename=(num=oldnum));
length num $100;
by id;
num=catx(',', num, oldnum);
if first.id then num=oldnum;
retain num;
run;
proc print data=want;
run;
@BrahmanandaRao wrote:
data in; infile datalines dlm='09'x; input id 1 num 3-4; datalines; 2 12 3 45 3 74 5 33 5 12 5 15 ; run;
I want output
ID Num 2 12 3 45,74 5 33,12,15 i
Hi dear
but i got output like below
| 2 | 12 |
| 3 | 45 |
| 3 | 45,74 |
| 5 | 33 |
| 5 | 33,12 |
| 5 | 33,12,15 |
Ah, sorry. Missed a statement. There u go 🙂
data in;
infile datalines dlm='09'x;
input id 1 num 3-4;
datalines;
2 12
3 45
3 74
5 33
5 12
5 15
;
data want(drop=oldnum);
set in(rename=(num=oldnum));
length num $100;
by id;
num=catx(',', num, oldnum);
if first.id then num=oldnum;
if last.id then output;
retain num;
run;
proc print data=want;
run;
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.