BookmarkSubscribeRSS Feed
techie123
Calcite | Level 5

When  I run the below code on SAS enterprise Guide 5.2, I am able to convert all the SAS datasets to Text files. But when I run the same code on SAS 9.2 it throws me below error: 

 

Error : "OUTPUT" is not a valid name

warning : " Apparent symbolic reference B not resolved"

ERROR : invalid data set name OUTPUT 

warning : " Apparent symbolic reference B not resolved"

 

Code :

 

libname OUTPUT 'P:\sample\SAS_check';

proc  sql ;

select memname into :b1 -: b3 from

dictionary.tables where libname = 'OUTPUT';

quit;

%macro txt;

%do i=1 %TO 3;

proc export data=OUTPUT.&&b&i

outfile="P:\sourcing\SAS_check\&&b&i...txt" dbms=tab replace; run;

%end;

%mend txt;

%txt

 

IF I want to implement the above code in SAS 9.2 what all changes do I need to make from the above code?

 

Thanks

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Please try the below code, i just included an additional dot after output libname in proc export

 

libname OUTPUT 'P:\sample\SAS_check';

proc  sql ;

select memname into :b1 -: b3 from

dictionary.tables where libname = 'OUTPUT';

quit;

%macro txt;

%do i=1 %TO 3;

proc export data=OUTPUT..&&b&i

outfile="P:\sourcing\SAS_check\&&b&i...txt" dbms=tab replace; run;

%end;

%mend txt;

%txt

Thanks,
Jag
ballardw
Super User

Do you actually have 3 data sets in the OUTPUT library? If not &b3 does not resolve.

 

Run your code with :

options mprint symbolgen;

%txt

 

 

And see if the log shows you an issue with one or more of your &b variables.

 

 

Tom
Super User Tom
Super User

I don't think using an old version of SAS will impact this program. Most likely your issue is that you are running on different data and so the program runs wrong.  Make the program more flexible so that it adapts to the data that is available.

 

Instead of hard coding the upperbound let SAS count for you.  This program should work fine with SAS9.2 (or even older).

 

%macro txt(libref,outdir=P:\sourcing\SAS_check);
%local i;
proc sql noprint ;
  select memname into :b1 - :b999999
    from dictionary.tables
    where libname = %upcase("&libref")
  ;
quit;
%do i=1 %to &sqlobs;
proc export data=&libref..&&b&i dbms=tab 
  outfile="&outdir\&&b&i...txt" replace
; 
run;
%end;
%mend txt;

libname OUTPUT 'P:\sample\SAS_check';
%txt(output);

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
  • 1208 views
  • 0 likes
  • 4 in conversation