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

I'm trying to organize a continuous variable into smaller blocks. For example. Im using CD4 counts 1-1500. I want to break the CD4 count variable into smaller blocks for analyzation. 1-200 would be low CD4. 201-500 would be medium CD4 level and 501 and above would be high CD4 level. 

 

what code would I use to do this, if it could be done? 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@UGAstudent wrote:

I'm trying to organize a continuous variable into smaller blocks. For example. Im using CD4 counts 1-1500. I want to break the CD4 count variable into smaller blocks for analyzation. 1-200 would be low CD4. 201-500 would be medium CD4 level and 501 and above would be high CD4 level. 

 

what code would I use to do this, if it could be done? 


An example:

proc format library=work;
/* Format names cannot end in a digit to
   avoid confusion with display length options
*/
value cd4_
0  -  200 = 'Low'
200<- 500 = 'Medium'
500<-high = 'High'
;
run;

proc freq data=yourdata;
  tables cd4;
  format cd4 cd4_. ;
run;

Formats are very powerful tools as you can create multiple formats and use as needed. Almost all of the analysis procedures will honor groupings assigned in custom formats.

 

View solution in original post

4 REPLIES 4
ballardw
Super User

@UGAstudent wrote:

I'm trying to organize a continuous variable into smaller blocks. For example. Im using CD4 counts 1-1500. I want to break the CD4 count variable into smaller blocks for analyzation. 1-200 would be low CD4. 201-500 would be medium CD4 level and 501 and above would be high CD4 level. 

 

what code would I use to do this, if it could be done? 


An example:

proc format library=work;
/* Format names cannot end in a digit to
   avoid confusion with display length options
*/
value cd4_
0  -  200 = 'Low'
200<- 500 = 'Medium'
500<-high = 'High'
;
run;

proc freq data=yourdata;
  tables cd4;
  format cd4 cd4_. ;
run;

Formats are very powerful tools as you can create multiple formats and use as needed. Almost all of the analysis procedures will honor groupings assigned in custom formats.

 

UGAstudent
Calcite | Level 5

This worked well. 

 

 

However, Im trying to do a linear regression but it says the newly created variables are not found? 

proc Reg data=Import;
title "Example of linear regression";
model Factor1 = Low;
run;

 

PaigeMiller
Diamond | Level 26

Low is not a variable. It is a formatted value.

 

If your goal is to do a regression on just the low values, none of the formatting is needed.

 

proc Reg data=Import(where=(0<=cd4<=200));
title "Example of linear regression";
model Factor1 = cd4;
run;

P.S.: It is always helpful to say what analysis you would like to do in your original post.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1496 views
  • 1 like
  • 4 in conversation