BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jermanie
Fluorite | Level 6

I got a code as shown below. How do I abbreviate the if statements in a way that goes like this Chile-Japan without typing every one of them?

 

data med;
infile "/folders/myshortcuts/sas/Vaccines.dat";
input
VacName $ 1-29
Mode $ 32-50
WInc 51-60
WDeath 61-70
Chile $ 71-73
Cuba $ 77-79
US $ 83-85
UK $ 89-91
Finland $ 95-97
Germany $ 101-103
SaudiArab $ 107-109
Ethiopia $ 113-115
Botswana $ 119-121
India $ 125-127
Australia $ 131-133
China $ 137-139
Japan $ 143-145
;
if WDeath = "" then WDeath = "0";
if WInc = "" then WDeath = "0";
if Chile = "" then Chile = "No";
if Cuba = "" then Cuba = "No";
if US = "" then US = "No";
if UK = "" then UK = "No";
if Finland = "" then Finland = "No";
if Germany = "" then Germany = "No";
if SaudiArab = "" then SaudiArab = "No";
if Ethiopia = "" then Ethiopia = "No";
if Botswana = "" then Botswana = "No";
if India = "" then India = "No";
if Australia = "" then Australia = "No";
if China = "" then China = "No";
if Japan = "" then Japan = "No";
run;

proc print data=med;
format WInc comma10. WDeath comma8.;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
kiranv_
Rhodochrosite | Level 12

something like this

 

data med;

set med;

array country{13} Chile Cuba US UK Finland Germany SaudiArab Ethiopia  Botswana India  Australia China Japan ;

do i = 1 to 13;

if country{i} = "" then country{i} ="No"

end;

drop i;

run;

View solution in original post

1 REPLY 1
kiranv_
Rhodochrosite | Level 12

something like this

 

data med;

set med;

array country{13} Chile Cuba US UK Finland Germany SaudiArab Ethiopia  Botswana India  Australia China Japan ;

do i = 1 to 13;

if country{i} = "" then country{i} ="No"

end;

drop i;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 842 views
  • 1 like
  • 2 in conversation