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?
@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.
Use proc format aka user defined format
This link might be of help-->
https://stats.idre.ucla.edu/wp-content/uploads/2016/02/bt3001.pdf
http://www2.sas.com/proceedings/sugi27/p056-27.pdf
@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.
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;
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.