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

Hello

 

data count;
input Age Salary;
datalines;
30 20000
31 20600
32 35000
35 50000
36 50000
31 36500
40 50000
30 80000
36 50000
;
run;

 

I would like to get output as below
            FRQ
30-35   6
36-40   3

 

Please help me with this.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Create a new variable that has your ranges, then run proc freq/tabulate. This you can try on your own. 

2. Use a format and run proc freq/tabulate. This is illustrated below.

 

proc format;
value age_fmt
30 - 35 = '30 to 35'
36 - 40 = '36 to 40';
run;

proc freq data=count;
format age age_fmt.;
table age/out=want;
run;

*output table want is also created if you want a data set;

View solution in original post

1 REPLY 1
Reeza
Super User

1. Create a new variable that has your ranges, then run proc freq/tabulate. This you can try on your own. 

2. Use a format and run proc freq/tabulate. This is illustrated below.

 

proc format;
value age_fmt
30 - 35 = '30 to 35'
36 - 40 = '36 to 40';
run;

proc freq data=count;
format age age_fmt.;
table age/out=want;
run;

*output table want is also created if you want a data set;

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
  • 726 views
  • 4 likes
  • 2 in conversation