Date: Mon, 13 Dec 2010 06:06:23 -0600
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Which Dataset is SET Currently Reading?
Content-Type: text/plain; charset=ISO-8859-1
You must have 9.2 for this new option. Otherwise you will have to use
creates and names a variable that stores the name of the SAS data set
from which the current observation is read. The stored name can be a
data set name or a physical name. The physical name is the name by
which the operating environment recognizes the file.
Tip: For data set names, SAS will add the library name to the variable
value (for example, WORK.PRICE) and convert the two-level name to
Tip: Unless previously defined, the length of the variable is set to
41 characters. Use a LENGTH statement to make the variable length long
enough to contain the value of the physical filename if it is longer
than 41 characters.
If the variable is previously defined as a character variable with a
specific length, that length is not changed. If the value placed into
the INDSNAME variable is longer than that length, then the value is
If the variable is previously defined as a numeric variable, an error
Featured in: Retrieving the Name of the Data Set from Which the
Current Observation Is Read
On Mon, Dec 13, 2010 at 3:24 AM, John Chapman
> If I have a SET statement reading more than one dataset my program can,
> of course, know which one it is currently on by using IN= .
> But what if I'm doing something like this...
> proc sql noprint;
> create table work.sales_files as
> select memname from dictionary.tables
> where upcase(libname='WORK'
> and upcase(memname) like 'SALES_%;
> select distinct memname into : sales_files separated by ' '
> from work.sales_files;
> data x;
> set &sales_files.;
> What can I put in that data step to give me the name of the dataset SET
> is currently reading?
> I bet there's an automatic macro symbol holding this information, but
> what's it called?