BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sammy2
Calcite | Level 5

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 🙂 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

1 REPLY 1
ballardw
Super User

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 204 views
  • 1 like
  • 2 in conversation