I have a Dataset TEST which has below variables Send, X, Y, C State . Need to calculate how many values are populated and what percentage of values populated for each variable when Send = Y and Sender =. by State
TEST
Send | X | Y | C | State |
Y | 1 | . | 100 | AL |
Y | 2 | . | 28 | AL |
Y | . | . | 56 | AL |
. | . | . | 55 | AL |
. | . | . | 77 | AL |
. | . | . | 30 | AL |
Y | 10 | 25 | 44 | PA |
Y | 20 | 32 | 89 | PA |
Y | 30 | 43 | 78 | PA |
. | 40 | 27 | 43 | PA |
. | . | 10 | 22 | PA |
. | . | . | 34 | PA |
Output should be something like
State = AL | |||||
Send=Y | Send=. | Send=Y | Send=. | Total Records | |
Count | Count | Percentage | Percentage | ||
X | 2 | 4 | 33.33 | 66.66 | 6 |
Y | 0 | 0 | 0 | 0 | 6 |
C | 3 | 3 | 50 | 50 | 6 |
Similarly for PA calculate the count of records populated and percentage of records populated when Send = Y and send =. for each variable by State
Can anyone please help ?
PROC TABULATE is your best bet for a displayed report and PROC MEANS for a data set. Do you need a data set or a report?
proc tabulate data=have;
by state;
class send x y c / missing;
table x y c, Send*(N) / printmiss misstext='0';
run;
This does not do the percentages though you can do that. See the documentation for examples for the percentages.
@jhh197 wrote:
I have a Dataset TEST which has below variables Send, X, Y, C State . Need to calculate how many values are populated and what percentage of values populated for each variable when Send = Y and Sender =. by State
TEST
Send X Y C State Y 1 . 100 AL Y 2 . 28 AL Y . . 56 AL . . . 55 AL . . . 77 AL . . . 30 AL Y 10 25 44 PA Y 20 32 89 PA Y 30 43 78 PA . 40 27 43 PA . . 10 22 PA . . . 34 PA
Output should be something like
State = AL Send=Y Send=. Send=Y Send=. Total Records Count Count Percentage Percentage X 2 4 33.33 66.66 6 Y 0 0 0 0 6 C 3 3 50 50 6
Similarly for PA calculate the count of records populated and percentage of records populated when Send = Y and send =. for each variable by State
Can anyone please help ?
PROC TABULATE is your best bet for a displayed report and PROC MEANS for a data set. Do you need a data set or a report?
proc tabulate data=have;
by state;
class send x y c / missing;
table x y c, Send*(N) / printmiss misstext='0';
run;
This does not do the percentages though you can do that. See the documentation for examples for the percentages.
@jhh197 wrote:
I have a Dataset TEST which has below variables Send, X, Y, C State . Need to calculate how many values are populated and what percentage of values populated for each variable when Send = Y and Sender =. by State
TEST
Send X Y C State Y 1 . 100 AL Y 2 . 28 AL Y . . 56 AL . . . 55 AL . . . 77 AL . . . 30 AL Y 10 25 44 PA Y 20 32 89 PA Y 30 43 78 PA . 40 27 43 PA . . 10 22 PA . . . 34 PA
Output should be something like
State = AL Send=Y Send=. Send=Y Send=. Total Records Count Count Percentage Percentage X 2 4 33.33 66.66 6 Y 0 0 0 0 6 C 3 3 50 50 6
Similarly for PA calculate the count of records populated and percentage of records populated when Send = Y and send =. for each variable by State
Can anyone please help ?
We can't use X Y or C as CLASS variables in Proc Tabulate, at least with the data values shown, as we get too many rows.
My headache with this is that @jhh197 wants to count a value of Send=Y in the Send=. cells. He is not counting missing Send but missing X in that case (the third row of data).
Thank you for all your help . When i ran the code below is the output . Here can i get the count of X , Y,C and percentage of X, Y,C instead of listing distinct values of X, Y,C when Send = Y and Send = . by State
State=AL
Send
Y
N N
X
. 3 1
1 0 1
2 0 1
Y
. 3 3
C
1 0 1
2 0 1
3 0 1
4 1 0
5 1 0
6 1 0
Thank you so much for all help
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.