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.
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.
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.