data ds;
infile datalines;
input id team$ loc$;
datalines;
10 red nlr
11 green tpt
12 tellow klr
;
run;
data ds1;
set ds;
if team='red' then members=' ravi, sekhar,pawan';
run;
output required ;
ravi
sekhar
pawan
i want vertical data expected output anyone can help me
output :
ravi, sekhar,pawan
anyone can help me
By 'vertical', do you mean that you want 1 obs per name if team = 'Red'?
Hi sir..
example :
if team=red then name=ravi, venu ,sai
when i am convert excel file in column output be like :
name
ravi
venu
sai
help me
data want;
set have (rename=(name=_name));
do i = 1 to countw(_name,",");
name = scan(_name,i,",");
output;
end;
drop i _name;
run;
Untested for lack of usable example data.
Output where? An external text file? An ODS destination? The Log? A data set with each value a separate observation?
This will print one word for each value of Members to the default output destination window.
data ds; infile datalines; file print; input id team$ loc$; if team='red' then members=' ravi, sekhar,pawan'; do i=1 to countw(members); word = scan(members,i); put word; end; datalines; 10 red nlr 11 green tpt 12 tellow klr ;
data ds (drop=members i); infile datalines; file print; input id team$ loc$; members=' ravi, sekhar,pawan'; do i=1 to countw(members); if team = 'red' then member = scan(members,i); output; end; datalines; 10 red nlr 11 green tpt 12 tellow klr ;
You can simply run a do loop for all the members and check for team red then output the appropriate member at the end of each iteration. However this will create 3 rows for each team since 3 members are specified at the beginning. Hope this helps!
Output:
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 lock in 2025 pricing—just $495!
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.