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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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