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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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