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

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
  • 3 replies
  • 1199 views
  • 0 likes
  • 4 in conversation