Date: Fri, 23 Mar 2012 09:51:55 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: User-Defined Format Name as Parameter in SAS Macro
In-Reply-To: <456B52C41B724C41B96561D7AD283E7D01F0570E@mail.chpdm.umbc.edu>
Content-Type: text/plain; charset=ISO-8859-1
In that case perhaps you don't need to burder the user with the
details just let them specify DXTYPE= that happens to aksi be the
names of your formats. No need introduce details to the user that are
not relevant.
Be sure to use KEEP= data set option on the DATA= option for PROC SORT
it will provide better performance if you only sort PDX and RECIPNO.
On 3/23/12, Jack Clark <jclark@hilltop.umbc.edu> wrote:
> _Null_,
>
> My macro is not creating a format statement, but using a format in a
> WHERE data set option. A section of the code is below...
>
> * recipients with at least 1 inpatient record ;
> proc sort data = medmed_inpt&yr1. (where=(put(pdx,$&dxfmt..) = "Y"))
> nodupkey
> out = &dxname._inpt&yr1. (keep=recipno);
> by recipno;
> run;
>
>
> DXFORMAT is the macro parameter, and will refer to 1 of 3 user-defined
> formats I have created (each is a list of Diagnostic Codes to identify
> different mental health categories). I am using the macro to process
> each format, then setting flags and merging the data sets.
>
> Thanks,
>
> Jack
>
>
>
>
>
>
>
> Jack Clark
> Senior Programmer
> phone: 410-455-6256
> fax: 410-455-6850
> jclark@hilltop.umbc.edu -----Original Message-----
> From: Data _null_; [mailto:iebupdte@gmail.com]
> Sent: Friday, March 23, 2012 10:26 AM
> To: Jack Clark
> Cc: SAS-L@listserv.uga.edu
> Subject: Re: User-Defined Format Name as Parameter in SAS Macro
>
> You might consider using a FORMAT= parameter that has the same syntax as
> the FORMAT statement.
>
> Format=<variable list> <formatname> ...,
>
> The use a FORMAT statement in your code at the appropiate place. Trap
> any non-zero return code to end the macro if there is a problem.
>
> This syntax is very flexable and users should already know how to use a
> FORMAT statement.
>
> On 3/23/12, Jack Clark <jclark@hilltop.umbc.edu> wrote:
>> Hello,
>>
>>
>>
>> I have a macro where I want one of the parameters to be the name of a
>> user-defined SAS character format. Are there any "best practices" or
>> "gotchas" I should be aware of with this?
>>
>>
>>
>> Is it preferred to put the full name of the format as the parameter
> (ex.
>> $schiz.), including the dollar sign and period - or should I put the
>> dollar sign and period in the macro code and only use the actual
> "name"
>> of the format in the macro parameter (ex. schiz, with the macro code
>> looking like...$&fmtnm..)?
>>
>>
>>
>> I wrote some code using the second approach described above, and it is
>
>> working. An unusual thing in the log is that the resolved macro
>> reference says $schiz1., not $schiz. - but as I said, it appears to
>> be working fine.
>>
>>
>> Any thoughts are appreciated.
>>
>>
>>
>>
>>
>> Jack
>>
>>
>>
>> Jack Clark
>> Senior Programmer
>> phone: 410-455-6256
>> fax: 410-455-6850
>> jclark@hilltop.umbc.edu
>>
>> University of Maryland, Baltimore County Sondheim Hall, 3rd Floor
>> 1000 Hilltop Circle
>> Baltimore, MD 21250
>>
>> Please consider the environment before printing this e-mail and/or any
>
>> attachments.
>>
>>
>> Confidentiality Notice: This e-mail may contain information that is
>> legally privileged and that is intended only for the use of the
>> addressee(s) named above. If you are not the intended recipient, you
>> are hereby notified that any disclosure, copying of this e-mail,
>> distribution, or action taken in reliance on the contents of this
>> e-mail and/or documents attributed to this e-mail is strictly
>> prohibited. If you have received this information in error, please
>> notify the sender immediately by phone and delete this entire e-mail.
> Thank you.
>>
>
|