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

Good morning SAS friends:

 

i hace this data set:

 

data have:

input ANIMAL    CG_GROW;

cards;
1    1
2    1
3    1
4    1
5    2
6    2
7    3
8    4
9    4
10    4
;

 

i need to obtain a summary info in the output describing the levels of CG_GROW variable and the number of the ocorrences like:

 

variable                  level          n

CG_GROW          1                4

CG_GROW          2                2

CG_GROW          3                1

CG_GROW          4                4

 

 

Thank you for your help

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Not tested yet as my SAS is working on something, but this should be near.

 

proc sql;
  create table WANT as
  select  "CG_GROW" as VARIABLE,
           CG_GROW as LEVEL,
           count(distinct ANIMAL) as N
  from     HAVE
  group by CG_GROW;
quit;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Not tested yet as my SAS is working on something, but this should be near.

 

proc sql;
  create table WANT as
  select  "CG_GROW" as VARIABLE,
           CG_GROW as LEVEL,
           count(distinct ANIMAL) as N
  from     HAVE
  group by CG_GROW;
quit;
Astounding
PROC Star

SAS has a very simple tool to create this type of report.  This should become part of your repertoire:

 

proc freq data=have;

tables cg_grow;

run;

 

 

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
  • 2 replies
  • 648 views
  • 1 like
  • 3 in conversation