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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1273 views
  • 2 likes
  • 3 in conversation