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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.