DATA Step, Macro, Functions and more

What is wrong with this?

Reply
Occasional Contributor
Posts: 14

What is wrong with this?

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.
Occasional Contributor
Posts: 14

Re: What is wrong with this?

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.
Super Contributor
Posts: 394

Re: What is wrong with this?

Probably you have < or > in your code. Here's how to post code in this forum.
Occasional Contributor
Posts: 14

Re: What is wrong with this?

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
Regular Contributor
Posts: 165

Re: What is wrong with this?

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.
Ask a Question
Discussion stats
  • 4 replies
  • 148 views
  • 0 likes
  • 3 in conversation