I am having variables stage wise. For example stage 1, stage2 and stage 3. It consist of values 0 and 1. If we assume for 10 applicants then how to count the no. of applicants in stage 1, like wise stage 2 and 3. Want to show each stage count.
Appli no stage1 stage2 stage3
1 0 1 1
2 1 0 0
3
4
5
6
7
8
9
10
I have done :
if stage1>0 then
return 1
else return 0
What output are you expecting from your code?
What do you mean by "return 1" ? - is it per row or per the whole data?
what variable should hold the result?
Alternative to @Patrick's solution you can use proc summary or proc means and some other procedures:
proc summary data=have <missing noprint>; * the last are optional;
class appli_no; /* or just class; for final total */
var stage1-stage3;
output out=result sum=;
run;
Providing a SAS data step creating the full sample data and showing the desired result would help.
Proc Summary might be what you're really after but given your a bit underspecified question here one way to go.
data have;
input Appli_no stage1 stage2 stage3;
datalines;
1 0 1 1
2 1 0 0
3 0 0 1
;
data want;
set have end=last;
retain s1 s2 s3;
s1+stage1;
s2+stage2;
s3+stage3;
if last then output;
keep s1 s2 s3;
run;
For sure.
add a dummy variable, like scope="all".
then use stageX variables as numeric variables with sum as aggregation.
have a list item with the scope variable and the stageX variables.
this should work for you.
I don't know all in's and out's of VA, but sponanously I think your data should be restructured so it can handle more dynamic requets.
a tronspose so you'll have:
Appli_no Stage
1 2
1 3
2 1
I see no immediately need to fill in stages with 0, but that depends what a 0 means in your original data. If you need it just an extra columns with 0/1.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.