Hi,
I have a dataset in which a column consist more than on value. I would like to split the column as per the number of values(As shown in the expected output).
A B
Agriculture 417,859
Power 0059
Real Estate 0038,622
Roads 3243
Telecom 0041
Expected Output
A B
Agriculture 417
Agriculture 859
Power 0059
Real Estate 0038
Real Estate 622
Roads 3243
Telecom 0041
Thanks in Advance
data want;
set have (rename=(B=oldB));
value_count = countw(oldB,',');
do i = 1 to value_count;
B = scan(oldB,i,',');
output;
end;
keep A B;
run;
data want;
set have (rename=(B=oldB));
value_count = countw(oldB,',');
do i = 1 to value_count;
B = scan(oldB,i,',');
output;
end;
keep A B;
run;
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.