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
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
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.
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);
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.
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.