BookmarkSubscribeRSS Feed
DartRodrigo
Lapis Lazuli | Level 10

Hi, 

I need a way to show just like the freq procedure the table below:

ID VALUE

1   10

2   10

3   10

4   30

 

I'd like to establish, if value is lower than 20 then it will represent a percentage, and so on.

I know there is a proc step to do this, i don't remember the name.

 

You guys have any idea ?

 

Thanks

 

 

5 REPLIES 5
ndp
Quartz | Level 8 ndp
Quartz | Level 8

create a format using proc format and then use it in proc freq.

DartRodrigo
Lapis Lazuli | Level 10

Actualy i need the proc step.

What i need is, establish tracks, just like:

 

if the value is lower than 10 then all values that are lower then 10 are in this group

if the value is lower than 20 then all values that are lower then 20 are in this group

if the value is lower than 30 then all values that are lower then 30 are in this group

 

I think there is a way to do this with proc tabulate but i don't remember how.

 

Steelers_In_DC
Barite | Level 11

You can either write it out using if - then or use proc format:

 

data have;
input ID VALUE;
cards;
1   10
2   15
3   20
4   30
;

proc format;
    value new low-10 = 1
              11-19  = 2
              20-29  = 3
              30-high= 4;
run;

data want;
set have;
if value < 11 then group = 1;
if 11 <= value < 20 then group = 2;
if 20 <= value < 30 then group = 3;
if value >= 30 then group = 4;
new_var = value;
format new_var new.;
run;

ndp
Quartz | Level 8 ndp
Quartz | Level 8

here is what i was talking about but there are plenty of other ways. You can adjust as per your needs.

 

data test;
input ID VALUE;
datalines;
1   10
2   20
3   10
4   30
run;

proc format;
	value grp low - 10 = '1'
			  10 <- 20 = '2'
			  20 <- high = '3'
	;
run;	

proc freq data=test;
	tables value;
	format value grp.;
run;

.  

Steelers_In_DC
Barite | Level 11

You should give an example of the data you have and what you want to see.  It's not perfectly clear what you are looking for here.

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
  • 5 replies
  • 943 views
  • 2 likes
  • 3 in conversation