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
Ammonite | Level 13

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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1507 views
  • 0 likes
  • 4 in conversation