BookmarkSubscribeRSS Feed
user1359
Calcite | Level 5

I don't know how to change my continous (yob) variable to discrete. I wanted the categories to look like this 

2001-1984 (21-32)

1983-1973 (33-43)

1972-1962 (50-60)

1961-1951 (61-71)

5 REPLIES 5
PaigeMiller
Diamond | Level 26
proc format;
    value yobf 1951-1962='61-71'
        1962-1972='50-60'
        1973-1983='33-43'
        1984-2001='21-32';
run;

 

Then in a data step or PROC, you assign the format to the variable.

 

format yob yobf.;
--
Paige Miller
user1359
Calcite | Level 5

Can you elaborate more 

PaigeMiller
Diamond | Level 26
proc format;
    value msrpf 0-25000='0-25K' 25000<-50000='25K-50K' 50000<-high='>50K';
run;

proc print data=sashelp.cars(obs=15);
    var make model msrp;
    format msrp msrpf.;
run;

PaigeMiller_0-1670192617841.png

 

--
Paige Miller
RosieSAS
Obsidian | Level 7

Just want to add a note that, FORMAT only changes how MSRP looks, not the real values of MSRP. So MSRP is still a numeric variable, not a discrete or categorical variable. 

SteveDenham
Jade | Level 19

Why do you want to discretize a continuous variable, other than to throw away valuable information?  See Regression Modeling Strategies, By Frank Harrell for reasons to avoid doing this.

 

SteveDenham

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 806 views
  • 2 likes
  • 4 in conversation