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

I am trying to make a character variable called SBPHypCat based on specifications of systolic blood pressure. So far I have this code:

 

data WORK.Illus;
set HypTabs.Src_Mississippi_VS;

if SBP = low - 90 then SBPHypCat = "Below Normal";
else if SBP = 90 - < 120 then SBPHypCat = "Normal";
else if SBP = 120 - < 140 then SBPHypCat = "High Normal";
else if SBP = 140 - < 160 then SBPHypCat = "Stage 1 Hypertension";
else if SBP = 160 - < 180 then SBPHypCat = "Stage 2 Hypertension";
else SBP = 180 - high then SBPHypCat = "Stage 3 Hypertension";
run;

 

I am getting a bunch of errors including:

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, INPUT, PUT.
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 202-322: The option or parameter is not recognized and will be ignored.
 
Is this just the wrong format to do this kind of task in, or is there another way for me to fix this?
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You're mixing the syntax for IF/THEN statements with the syntax for creating a format.  Here's how IF/THEN statements would look:

 

data Illus;

set HypTabs.Src_Mississippi_VS;

length SBPHypCat $ 22;

if SBP <= 0 then SBPHypCat='Bad Measurement';

else if SBP <= 90 then SBPHypCat = 'Below Normal';

else if SBP <= 120 then SPBHypCat = 'Normal';

 

else if SBP <= 140 then SBPHypCat = 'High Normal';

else if SBP <= 160 then SBPHypCat = 'Stage 1 Hypertension';

else if SBP <= 180 then SBPHypCat = 'Stage 2 Hypertension';

else SBPHypCat = 'Stage 3 Hypertension';

run;

 

 

View solution in original post

4 REPLIES 4
Astounding
PROC Star

You're mixing the syntax for IF/THEN statements with the syntax for creating a format.  Here's how IF/THEN statements would look:

 

data Illus;

set HypTabs.Src_Mississippi_VS;

length SBPHypCat $ 22;

if SBP <= 0 then SBPHypCat='Bad Measurement';

else if SBP <= 90 then SBPHypCat = 'Below Normal';

else if SBP <= 120 then SPBHypCat = 'Normal';

 

else if SBP <= 140 then SBPHypCat = 'High Normal';

else if SBP <= 160 then SBPHypCat = 'Stage 1 Hypertension';

else if SBP <= 180 then SBPHypCat = 'Stage 2 Hypertension';

else SBPHypCat = 'Stage 3 Hypertension';

run;

 

 
marianhabesland
Calcite | Level 5

That makes sense. I just worked on formats, so did not release it had different syntax. Thanks!

Reeza
Super User

@marianhabesland wrote:

That makes sense. I just worked on formats, so did not release it had different syntax. Thanks!


If this is for homework, you may have been expected to use a format to do the conversion, not IF/THEN statements. 

Once you have the format it would look like:

 

SBPHypCat = put( SBP, sbp_format.);
WarrenKuhfeld
Rhodochrosite | Level 12

This is not the syntax for boolean expressions in IF statements.  Here are some examples.  Substitute expressions for x and y.  Notice there are no dashes or low or high.

 

x = y

x <= y

x < y

x > y

x >= y

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
  • 4 replies
  • 1202 views
  • 0 likes
  • 4 in conversation