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.
3 REPLIES 3
Peter_C
Rhodochrosite | Level 12
> 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.

apart from anything else, you don't know how to use macro variables in a data step
> call symput('j',x);
> if
> /*blablablabla*/
> then Exp&j=Price;

&j gets the compile-time value, not the run time value
Until you appreciate this, avoid call symput()
ArtC
Rhodochrosite | Level 12
You will also want to look at the form of the iterative DO statement. I doubt that this one will do what you intend.

do i=1 to i le 14;

Art
Peter_C
Rhodochrosite | Level 12
ArtC's point is fundamental to learning SAS programming. Data processing like iterative DO loops is central to the purpose and capabilities of DATA steps.
It is possible you want subscripting to select fom a list. That functionality is a typical activity used in an iteration. SAS provides that in DATA steps with ARRAY handling. Not with ampersand.
To learn the basics of SAS programming read and try the examples in Documentation.

welcome to SAS

peterC

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