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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.