My task is I want to count the number of pop cont and can cont under each of the variables lung loat lsquam ladeno.
As I look at the output in your attached file, it seems as if you have programmed SAS to do this counting. So I'm not sure what you are asking.
This is overkill for what you want but definitely gives you that.
https://gist.github.com/statgeek/2de1faf1644dc8160fe721056202f111
Otherwise a PROC MEANS is likley all you need, assuming numeric variables - results are stored in the 'want' data set. The solution above works regardless of types.
proc means data=sashelp.class N NMISS;
ods output summary=want;
run;
proc print data=want;
run;
@ak2011 wrote:
Hi,I would greatly appreciate if somone could help me with the SAS code to count number of observations/records under each column variable in the attached table(Table 1).My task is I want to count the number of pop cont and can cont under each of the variables lung loat lsquam ladeno.I know that probably I need to use proc means or proc freq to do the counts but I am not sure about the right code.Any help,please? Thanks in advance.ak.1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7273 /* Cell Types*/74 data ncells(keep=lung loat lsquam ladeno);75 set bgmg1(obs=70);76 run;NOTE: There were 70 observations read from the data set WORK.BGMG1.NOTE: The data set WORK.NCELLS has 70 observations and 4 variables.NOTE: DATA statement used (Total process time):real time 0.01 secondscpu time 0.02 seconds7778 proc print data=ncells;79 Title " Table 1. Cancer information";80 run;NOTE: There were 70 observations read from the data set WORK.NCELLS.NOTE: PROCEDURE PRINT used (Total process time):real time 0.43 secondscpu time 0.43 seconds8182 proc freq data=ncells;83 run;NOTE: There were 70 observations read from the data set WORK.NCELLS.NOTE: PROCEDURE FREQ used (Total process time):real time 0.24 secondscpu time 0.23 seconds8485 proc means data=ncells; run;NOTE: There were 70 observations read from the data set WORK.NCELLS.NOTE: PROCEDURE MEANS used (Total process time):real time 0.17 secondscpu time 0.15 seconds868788 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;100
You may get a better answer if you provide:
1) a small example data set as data step code.
2) What you expect for the result given that example data.
The example should be big enough to demonstrate some difference in the resulting count but small enough you can create the output by hand to show the desired result and layout.
Here's something similar to what I think you are wanting, a single table with the counts per column heading.
data example; input var1 $ var2 $ var3 $; datalines; A B A A A B A B B A B A B B B B A A B B A ; data temp; set example; array v var1 var2 var3; do i=1 to dim(v); name = vname(v[i]); value = v[i]; output; end; run; proc tabulate data=temp; class name value; table value,name ; run;
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!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.