|Date: ||Thu, 30 Apr 2009 14:02:32 -0500|
|Reply-To: ||Tim Kynerd <tkynerd@ECD.ORG>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Tim Kynerd <tkynerd@ECD.ORG>|
|Subject: ||Re: A macro question|
|Content-Type: ||text/plain; charset="utf-8"|
The PROC CONTENTS looks in the SAS library (here, TEMP) and creates a SAS table called CONT with information about each table in the library.
The PROC SORT sorts CONT by MEMNAME, which is the name of each table in the library (TEMP). Since CONT doesn't need to be sorted for the processing that follows, I assume that the point is the NODUPKEY, which will delete any duplicate observations for the same value of MEMNAME. Thus (see below), each table in TEMP will only get processed once.
The macro runs a DATA step that re-creates a table in TEMP. The &TABLE variable will have the name of a table in TEMP as its value. The "Table=" statement creates a new variable on the table being processed, with the value of &TABLE as its value. In other words, the macro adds, to the table it's processing, a variable called Table whose value is the name of that table.
The DATA _NULL_ step simply calls the macro for each observation in CONT, passing the name of the table (MEMNAME) to the macro as a parameter. (In the macro, this parameter is &TABLE.)
I don't know why this would be necessary, but the overall idea is to add, to every table in a library, a new variable containing the name of the table. This variable will have the same value for every observation.
I hope this helps.
4 Old River Place, Suite A
Jackson, MS 39202
P: (601) 944-9308
F: (601) 944-0808
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith
Sent: Thursday, April 30, 2009 1:40 PM
Subject: A macro question
I am trying to learn from it. Can anyone please tell me what each line is
doing here? Also, what would be the best purpose for this macro?
Proc contents data=temp._all_ out=cont (keep=memname) noprint;
Proc sort nodupkey;
Call execute (â€˜%mac(â€˜||memname||â€™)â€™);
Please do not laugh at me. I am very new to macro.
This transmission is intended only for the use of the addressee and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If you are not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately via e-mail at firstname.lastname@example.org.