BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
NewUsrStat
Lapis Lazuli | Level 10

Hi guys, 

 

I'm trying to load dictionary tables in my script. 

To do this I used the following: 

 

 

libname coding "&path.\db_coding";

proc sql;
    select cats('data ', memname, '; set coding.', memname, '; run;')
    into :loading_code separated by '  '
    from dictionary.tables
    where libname = "CODING"; 
quit;

&loading_code;

The files are named: 

rtv_ascn_pv

tvx_tpr_pf

Iit_scn_mn

 

While running the code I'm getting the following error: 

 

36         &loading_code;
NOTE: Line generated by the macro variable "LOADING_CODE".
36           dataRTV_ASCN_PV;
             ______________
             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: Line generated by the macro variable "LOADING_CODE".
36                           set coding.RTV_ASCN_PV;
                             ___
                             180

ERROR 180-322: Statement is not valid or it is used out of proper order.

Can anyone help me understanding what happening? 

 

It seems a syntax issue. 

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

SAS did what you asked it to do, remove the spaces between the strings.

 

Try using CATX() instead.

select catx(' ','data', memname, ';set',catx('.',libname,memname), ';run;')
    into :loading_code separated by '  '

If you are copying actual datasets (and not physicalizing views) then  just use PROC COPY.

proc copy in=CODING out=work memtype=data;
run;

If you only want some of the members then just generate the list of member names into a macro variable.

select memname into :memlist separated by ' ' ...

And use it to generate a SELECT statement for the PROC COPY step.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

SAS did what you asked it to do, remove the spaces between the strings.

 

Try using CATX() instead.

select catx(' ','data', memname, ';set',catx('.',libname,memname), ';run;')
    into :loading_code separated by '  '

If you are copying actual datasets (and not physicalizing views) then  just use PROC COPY.

proc copy in=CODING out=work memtype=data;
run;

If you only want some of the members then just generate the list of member names into a macro variable.

select memname into :memlist separated by ' ' ...

And use it to generate a SELECT statement for the PROC COPY step.

Kurt_Bremser
Super User

CATS removes trailing blanks from all arguments, even if they are string constants. You can use the CAT function instead, as the blanks between the dataset names and the semicolons won't matter.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 290 views
  • 1 like
  • 3 in conversation