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