BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

 

Hi...I am trying to run the proc contents procedure on a number of datasets. The list of names for the datasets are selected from List2. I only want to run the proc contents for each dataset name that is stored in the tablelist. I have attached part of the log output at the end of the code. Any suggestion why I am getting the error. Thanks.

 

proc sql noprint;
	select distinct
		count(tbl)
		into : countlist separated by ' '
	from work.List2
	where List2.ct > 0;
quit;

%put &countlist;

proc sql noprint;
	select distinct
		tbl
		into : tablelist separated by ' '
	from work.List2
	where List2.ct > 0;
quit;

%put &tablelist;
%macro list1;
%local i;
%do i=1 %to &countlist;
%let Dn=%scan(&tablelist,&i);
	LTable="&Dn";

proc contents data=sqldb.&LTable varnum details;
run;

%end;
%mend;
%list1;

Log output:

1         %list1;
NOTE: Line generated by the invoked macro "LIST1".
71          LTable="&Dn";
            ______
            180

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

WARNING: Apparent symbolic reference LTABLE not resolved.
&LTable
WARNING: Apparent symbolic reference LTABLE not resolved.
NOTE 137-205: Line generated by the invoked macro "LIST1".
71          proc contents data=sqldb.&LTable varnum details; run;
                                     _
                                     22
ERROR 22-322: Syntax error, expecting one of the following: ;, (, CENTILES, DATA, DETAILS, DIR, DIRECTORY, FMTLEN, LIB, MEMTYPE, 


              MT, MTYPE, NODETAILS, NODS, NOPRINT, ORDER, OUT, OUT2, SHORT, VARNUM. 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. You should use PROC DATASETS or SASHELP.VTABLE instead to process all instead of one at a time.

 

For your current code, you forgot the %LET in front of the line with the error.

 

 

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

1. You should use PROC DATASETS or SASHELP.VTABLE instead to process all instead of one at a time.

 

For your current code, you forgot the %LET in front of the line with the error.

 

 

 

 

twildone
Pyrite | Level 9

Hi Reeza.....thanks for the quick response. The missing %let was the problem...thanks once again.

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
  • 717 views
  • 0 likes
  • 2 in conversation