BookmarkSubscribeRSS Feed
nidhi123
Calcite | Level 5
do i=1 to i<=14;
x=i;
call symput('j',x);
if
/*blablablabla*/
then Exp&j=Price;

i=i+1;
end;

I get the error message:
(for the Exp&j=Price statement I have used.)
ERROR 180-322: Statement is not valid or it is used out of proper order.
4 REPLIES 4
nidhi123
Calcite | Level 5
Here is my question. Something wrong with this forum today??

do i=1 to i<=14;
x=i;
call symput('j',x);
if
/*blablablabla*/
then Exp&j=Price;

i=i+1;
end;

I get the error message:
(for the Exp&j=Price statement I have used.)
ERROR 180-322: Statement is not valid or it is used out of proper order.
Tim_SAS
Barite | Level 11
Probably you have < or > in your code. Here's how to post code in this forum.
nidhi123
Calcite | Level 5
THANKS TIM@SAS!



Here is my problem:
I get this error:

Statement is not valid or it is used out of proper order.

for running this code:

DATA new;
set old;
do i=1 to i<=14;
x=i;
call symput('j',x);
if Post in ('010')
then Exp&j=Price;

i=i+1;
end;

run;


SAS dont like me setting Exp&j = Price
RickM
Fluorite | Level 6
First, your do loop is not defined well for SAS. You can just write

[pre]
do i=1 to 14;
"Do stuff here"
end;
[/pre]

Another thing is that macro variables can't be used within the same data step that they are created.

Arrays would probably do what it looks like you are trying to do.

[pre]
data new;
set old;
array Exp(14);
do i=1 to 14;
if Post in ('010') then Exp(i)=Price;
end;
run;

[/pre]

But then you will just get 14 colums with the same value. Maybe you could try and explain what you want to do.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 733 views
  • 0 likes
  • 3 in conversation