Date: Thu, 13 Mar 2003 11:08:16 -0500
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: Extracting the dataset name
Content-Type: text/plain; charset="iso-8859-1"
Patrice,
In general, no, you have to supply the work. Since you do not supply the
source of the names, I will simply hard code them.
data work.something ;
array __src (6) $32 _temporary_ ( "Table1" "Table2" ... ) ;
*note list of tables is prbably a macrovariable ;
set SQLDB.Table1 ( in = in1 )
SQLDB.Table2 ( in = in2 )
SQLDB.Table3 ( in = in3 )
SQLDB.Table4 ( in = in4 )
SQLDB.Table5 ( in = in5 )
SQLDB.Table6 ( in = in6 )
;
__source = in1 + 2*in2 + 3*in3 + 4*in4 + 5*in5 + 6*in6 ;
source = __src ( __source ) ;
drop __: ;
<remainder of code>
run ;
I would package it as a macro with two parameters the list of datasets and
the name of the final source variable with default SOURCE. The macro would
generate the ARRAY, SET, and __SOURCE assignment statements. So the user
code might look like
data work.something ;
%bigset ( dslist = &list )
<remainder of code>
run ;
where LIST is a macro variable generated by some other part of the system.
The above is untested code, but I have used similar schemes many times.
IanWhitlock@westat.com
-----Original Message-----
From: Patrice.Bourdages@IAAH.CA [mailto:Patrice.Bourdages@IAAH.CA]
Sent: Thursday, March 13, 2003 9:46 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Extracting the dataset name
I have a strange case for all of you...
I have the following code (shortened for the exercice):
data work.something;
set SQLDB.Table1
SQLDB.Table2
SQLDB.Table3
SQLDB.Table4
SQLDB.Table5
SQLDB.Table6;
*** some SAS code;
run;
I need to be able to identify where the observation came from. The thing is
that the Table list shown here is fix for this exercice but comes from a
macro variable created with all the tables contained in that database on the
server SQL. Of course, the Table1-Table6 listed here are not the real name
employed on that server. The name doesn't really matter, but are changing
almost everyday day.
Is there a way to know from witch table an observation came from using some
sort of environnement variable. You understand that I cannot use (in=a)
since I never know in advance what would be the table names on the SQL
server database.
Something like: ObsComingFrom = (Table1); when that obs come from that table
or something like that...
TIA for your always precious help.
Patrice Bourdages
Information System Analyst
Industrial Alliance, car and home insurance