BookmarkSubscribeRSS Feed
asundha
Calcite | Level 5

data reg;
set oriontst.REGION;

if country =('CA' , 'AU') then
do;
discount=0.10;
discount_type='required';
region='north_america';
end;
else if country ='OTHERS' then
do;
discount=0.05;
discount_type='optional';
region NE 'north_america';
end;
run;

 

 

My errors:

71 data reg;
72 set oriontst.supplier;
73
74 if country =('CA' , 'AU') then
_
388
200
75 do;
__
180
ERROR 388-185: Expecting an arithmetic operator.
 
ERROR 200-322: The symbol is not recognized and will be ignored.
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
76 discount=0.10;
77 discount_type='required';
78 region='north_america';
79 end;
___
161
80 else if country ='OTHERS' then
____
160
ERROR 161-185: No matching DO/SELECT statement.
 
ERROR 160-185: No matching IF-THEN clause.
 
81 do;
82 discount=0.05;
83 discount_type='optional';
84 region NE 'north_america';
______
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
85 end;
86 run;
13 REPLIES 13
novinosrin
Tourmaline | Level 20

use IN operator

 

if country  IN ('CA' , 'AU')

asundha
Calcite | Level 5
If I use in also
I'm getting error like this
Statement is not valid or it is used out of order
novinosrin
Tourmaline | Level 20

I think that's because

 

region NE 'north_america'; /*wrong assignment*/

 

is wrong in your else clause

 

 

 

else if country ='OTHERS' then
do;
discount=0.05;
discount_type='optional';
region NE 'north_america';   Wrong
end;

 

 

 

asundha
Calcite | Level 5

ok then what is the correct code .

see in the attachment(task) below.

asundha
Calcite | Level 5
just now i was added the task in attachment
asundha
Calcite | Level 5
 
novinosrin
Tourmaline | Level 20

Correction:

 

 

region = 'NOT north_america';
Kurt_Bremser
Super User

@asundha wrote:
If I use in also
I'm getting error like this
Statement is not valid or it is used out of order

The log points you to invalid code, and see my previous post.

PaigeMiller
Diamond | Level 26
if country =('CA' , 'AU') then do;

This is not proper syntax. You want

 

if country in ('CA','AU') then do;

In the future, please click on the {i} icon and paste your log into this window. We need to see your log, and we need to see it formatted properly for ease of reading, so please DO NOT SKIP THIS STEP.

--
Paige Miller
Kurt_Bremser
Super User

Use the in operator:

if country in ('CA','AU') then do;

and

region NE 'north_america';

is not a valid SAS statement. What should it do?

 

PS see my footnotes for hints on posting code and logs ({i} and "little running man" buttons).

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, we are really not here to do your homework.  That question is very simple, and it is for you to do the programming on.  If you have specific questions, come back with them, show what you have done and where you are stuck, and avoid using attachments - put text in the body of the post.

Reeza
Super User
Comment every line and you'll find your mistake.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 13 replies
  • 10897 views
  • 0 likes
  • 6 in conversation