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;
Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.
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.