Splitting the data in to differnt rows id name value2 value3 1 a,b a:1,b:1 a:2,b:2 2 a,b a:3,b:4 a:3,b:4 3 a a:5 a:6 4 a,b,c,d a:10,b:20 c:30 d:40 a:10,b:20 c:30 d:40 Output I am having a variable Name it should split base on the commas and the correspoding value(value2 and value3) sould come. id Name value2 value3 1 a a:1 a:2 1 b b:1 b:2 2 a a:3 a:3 2 b b:4 b:4 3 a a:5 a:6 4 a a:10 a:10 4 b b:20 b:20 4 c c:30 c:30 4 d d:40 d:40 For ef you can view in txt
EASY.
data have; input id name & $20. value2 & $20. value3 & $20.; cards; 1 a,b a:1,b:1 a:2,b:2 2 a,b a:3,b:4 a:3,b:4 3 a a:5 a:6 4 a,b,c,d a:10,b:20 c:30 d:40 a:10,b:20 c:30 d:40 ; run; data want(drop=value: i n name); set have; length _name _value2 _value3 $ 20; n=max(countw(value2,', '),countw(value3,', ')); do i=1 to n; _name=scan(name,i,', '); _value2=scan(value2,i,', '); _value3=scan(value3,i,', '); output; end; run;
Ksharp
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.