BookmarkSubscribeRSS Feed
wbrown
Calcite | Level 5

My original output shows as 

(1)Large

(2)average

(3)small

(4)very small

 

and I want to recode the "large" and "average" as 1

and "small" and "very small" as 0

all others will be missing. 

 

How do I do this in sas? Thanks!

1 REPLY 1
slacey
Obsidian | Level 7

While you could use a set of if-then-else statements to accomplish that, here's an alternative to that approach:

 

 

data ds1;
    length score $20;
    input subjid 1 score $ 4-13;

datalines;
1  Large
2  average
3  small
4  very small
5  Large
6  ittybitty
7  small
8  very small
9  not large
10 average
11 small
12 very small
;
run;

proc format;
    invalue likertf "Large","average"=1
		    "small","very small"=0
		    other=.;
run;

data ds2;
    set ds1;

    likertnum = input(score,likertf.);
run;

 

sas-innovate-2024.png

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.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 676 views
  • 0 likes
  • 2 in conversation