data new.newshoes;
set sashelp.shoes; /* the original data set */
if PRODUCT = "Boot" then NEWPRODUCT=1;
if PRODUCT = "Men's Casual" then NEWPRODUCT=2;
if PRODUCT = "Women's Casual" then NEWPRODUCT=3;
if PRODUCT = "Men's Dress" then NEWPRODUCT=4;
if PRODUCT = "Women's Dress" then NEWPRODUCT=5;
if PRODUCT = "Sandal" then NEWPRODUCT=6;
if PRODUCT = "Slipper" then NEWPRODUCT=7;
if PRODUCT = "Sport Shoe" then NEWPRODUCT=8;
format NEWPRODUCT productfmt.;
run;
One thing: the embedded ifn() suite above would be a wee bit slower than a suite of if else statement as sas in their wisdom have chosen to always evaluate all arguments of the ifn/ifc functions, even though by design some will never be used. I hope that one day C=ifn(B=0,.,A/B); will not generate a division by zero error when B=0. It shouldn't.
Anyway, I am ready to trade the tiny performance hit for better code legibility.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.