While I generally dont like the approach, you can ise nested IFC Functions like this
data have;
do value=0 to 100;
output;
end;
run;
data want;
set have;
severity=ifc(value ge 80, "Severe", ifc(value ge 20, "Moderate", "Mild"));
run;
While I generally dont like the approach, you can ise nested IFC Functions like this
data have;
do value=0 to 100;
output;
end;
run;
data want;
set have;
severity=ifc(value ge 80, "Severe", ifc(value ge 20, "Moderate", "Mild"));
run;
@Bhavanaa44 wrote:
As IFC and IFN can be used in place of IF-THEN-ELSE
But how to create more than 2 codes such as mild, moderate, and Severe.
Do help me.
Use a value format with ranges. All the conditions turn into a single put().
I very much agree with @Kurt_Bremser.
If a category is based on a single variable then a custom format is a very superior way to handling for a number of reasons.
One of the most flexible elements of formats is the ability to use different formats with the same variable to create different groups for
analysis or reporting. Most of the modeling, analysis and graphing procedures will honor groups created by a format.
See below for an example. Notice that NO additional variables are created.
proc format library=work; value mild_sev 0 - 20='Mild' 20<-80='Moderate' 80<-high='Severe' ; value mild_vsev 0 - 20='Mild' 20<-40='Less Moderate' 40<-90='High Moderate' 90<-high='Very Severe' ; run; data have; do value=0 to 100; output; end; run; title 'Mild to servere format'; proc freq data=have; tables value; format value mild_sev.; run; title 'Mild to very severe format'; proc freq data=have; tables value; format value mild_vsev.; run; title;
@Bhavanaa44, glad to know that it worked. However, it is a much better solution to use formats, especially when you add more categories.
Regards.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: