BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello,

For some reason the symput variable I'm using won't work with a table name I'm creating. Is there any way around this?

ERROR 202-322: The option or parameter is not recognized and will be ignored.

ERROR 22-322: Syntax error, expecting one of the following: (, AS, LIKE.



libname t '/sas/userdata/mine';

data _null_;
tod_date = date();
call symput('todaydate', tod_date);
run;

proc sql;
create table t.rec_m_list&todaydate as
select * from t.data_table;
quit;
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Reply again with a complete SAS log, using the additional OPTIONS statement, which may help self-diagnose the error:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT;

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
> Hello,
>
> For some reason the symput variable I'm using won't
> work with a table name I'm creating. Is there any way
> around this?
>
> ERROR 202-322: The option or parameter is not
> recognized and will be ignored.
>
> ERROR 22-322: Syntax error, expecting one of the
> following: (, AS, LIKE.
>
>
>
> libname t '/sas/userdata/mine';
>
> data _null_;
> tod_date = date();
> call symput('todaydate', tod_date);
> run;
>
> proc sql;
> create table t.rec_m_list&todaydate as
> select * from t.data_table;
> quit;

ScottP1
it is obvious (once you know 15 answers - obvious millionaire time 😉 too )
So remember that macro variables are strings, so
> call symput('todaydate', tod_date);
converts the value in tod_date to a string with default conversion.
Better in SAS9 is symputX() which suppresses the NOTE about numeric to character conversion and removes leading and trailing blanks from the value pushed into the macro variable 'todaydate'.
Your problem was probably caused by leading blanks in the value in &todaydate.

Another issue might strike you once you solve that leading blank problem.
The value is just a number, because sas supports dates by storing them as a number and providing a wealth of formats to present dates.
So, table t.rec_m_list&todaydate would become something like t.rec_m_list18362 on 10-Apr-2010.
If you wanted t.rec_m_list20100410, you could use
>> call symput('todaydate', put(tod_date, yymmddN8.) );
That put() function creates a date string just 8 digits wide, so no blanks.

but I wouldn't use nor recommend a datastep for this kind of thing.
Are you ready for %sysfunc() ? Check it out in on the sas support web site. Here is my take on achieving what you seem to seek

%let todayDate = %sysfunc( date(), yymmddN8 );
> proc sql;
> create table t.rec_m_list&todaydate as
> select * from t.data_table;
> quit;
Alternative formats have inconveniences like not sorting well when a list of these tables is sorted by name, or containing invalid characters like /

have a look at call symputX() and %sysfunc(). Not only do I think you'll find it informative. I think you'll come up with even better ways to use these features.

Look forward to hearing more from you ScottP1, demonstrating new found learning.

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