BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_it
Quartz | Level 8

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
FredrikE
Rhodochrosite | Level 12
One way could be to have three different objects, one for each stage. The objects show the sum of stage1, stage2 and stage3.
You can add labels and text to each object to tell what stage is shown.
I don't really understand why you need to create a hierarchy, could it not be done just graphically?

//Fredrik

View solution in original post

15 REPLIES 15
Shmuel
Garnet | Level 18

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?

sas_it
Quartz | Level 8
I want the total count of each stage and I will be creatiNg the hierarchy of the stages.
Shmuel
Garnet | Level 18

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;
sas_it
Quartz | Level 8
I need total count of the variable.
Patrick
Opal | Level 21

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;

 

Patrick_0-1634045095509.png

 

sas_it
Quartz | Level 8
Can we directly in VA?
acordes
Rhodochrosite | Level 12

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.

sas_it
Quartz | Level 8
I am already haviNg stages variables in numeric. But when I convert that to category to create hierarchy , does it effect result or count..
sas_it
Quartz | Level 8
Can we directly in VA? I want to create hierarchy and having different stages data and custom category of the stages also. Each stage having the values 0 and 1. But I want to take only one which signifies completed.
LinusH
Tourmaline | Level 20

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.

 

Data never sleeps
sas_it
Quartz | Level 8
1 means completed.
LinusH
Tourmaline | Level 20
But what does 0 mean?
Have been enrolled and not completed, or perhaps not even enrolled?
Data never sleeps
sas_it
Quartz | Level 8
Actually I just want the count of 1 which means completed. 0 means not completed but I don't want that.
FredrikE
Rhodochrosite | Level 12
One way could be to have three different objects, one for each stage. The objects show the sum of stage1, stage2 and stage3.
You can add labels and text to each object to tell what stage is shown.
I don't really understand why you need to create a hierarchy, could it not be done just graphically?

//Fredrik

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 15 replies
  • 1478 views
  • 7 likes
  • 6 in conversation