BookmarkSubscribeRSS Feed
data_null__
Jade | Level 19

The following code will generate a LIBREF named as MC0000nn.  But I cannot figure out how to know the generated name.  The FILENAME function has similar feature that populates the variable with the generated FILEREF.

 

6
7    data _null_;
8       length libref $8;
9       libref = ' ';
10      rc = libname(libref,'.');
11      msg = sysmsg();
12      put _all_;
13      run;

libref=  rc=-70004 msg=NOTE: Libref  refers to the same physical library as SASUSER. _ERROR_=0 _N_=1
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

SASHELP.VLIBNAM before and after.

BeforeBeforeAfterAfter

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Not too sure why you'd want to define a nameless library, but you can get the name by defining another library that points to the same location:

 

data _null_;
  length LIBREF $8;
  LIBREF = ' ';
  RC  = libname(LIBREF,'.');
  RC  = libname(LIBREF,'.');
  MSG = sysmsg();
  put _all_;
run;

LIBREF= RC=-70004 MSG=NOTE: Libref refers to the same physical library as WC000001. _ERROR_=0 _N_=1

 

A bit wasteful but better than nothing?

 

 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1278 views
  • 0 likes
  • 2 in conversation