Hi,
There is three different eye colors in the example data Color (https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_freq_examples01.htm)
How do I get SAS to tell me that there is three different eye colors? So I would need number 3 from the dataset 🙂
Not very specific on how you want the number "3".
With this data set from the example:
data Color; input Region Eyes $ Hair $ Count @@; label Eyes ='Eye Color' Hair ='Hair Color' Region='Geographic Region'; datalines; 1 blue fair 23 1 blue red 7 1 blue medium 24 1 blue dark 11 1 green fair 19 1 green red 7 1 green medium 18 1 green dark 14 1 brown fair 34 1 brown red 5 1 brown medium 41 1 brown dark 40 1 brown black 3 2 blue fair 46 2 blue red 21 2 blue medium 44 2 blue dark 40 2 blue black 6 2 green fair 50 2 green red 31 2 green medium 37 2 green dark 23 2 brown fair 56 2 brown red 42 2 brown medium 53 2 brown dark 54 2 brown black 13 ;
My first though would be the NLEVELS option in Proc Freq.
proc freq data=color nlevels; tables eyes; run;
That will report on the number of different values. With ODS SELECT you could restrict the output to only include the Nlevels output but I'm not quite sure what you are looking for.
Not very specific on how you want the number "3".
With this data set from the example:
data Color; input Region Eyes $ Hair $ Count @@; label Eyes ='Eye Color' Hair ='Hair Color' Region='Geographic Region'; datalines; 1 blue fair 23 1 blue red 7 1 blue medium 24 1 blue dark 11 1 green fair 19 1 green red 7 1 green medium 18 1 green dark 14 1 brown fair 34 1 brown red 5 1 brown medium 41 1 brown dark 40 1 brown black 3 2 blue fair 46 2 blue red 21 2 blue medium 44 2 blue dark 40 2 blue black 6 2 green fair 50 2 green red 31 2 green medium 37 2 green dark 23 2 brown fair 56 2 brown red 42 2 brown medium 53 2 brown dark 54 2 brown black 13 ;
My first though would be the NLEVELS option in Proc Freq.
proc freq data=color nlevels; tables eyes; run;
That will report on the number of different values. With ODS SELECT you could restrict the output to only include the Nlevels output but I'm not quite sure what you are looking for.
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.