Date: Fri, 3 Nov 2000 17:48:45 -0500
Reply-To: michael.walega@COVANCE.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Walega <michael.walega@COVANCE.COM>
Subject: Re: function question
Content-Type: multipart/mixed;
Try the attached macro.
Mike
______________________________ Reply Separator _________________________________
Subject: function question
Author: Brispac <brispac@FRONTIERNET.NET> at EMAIL-GATEWAY
Date: 11/03/2000 5:35 PM
Hello,
I have a macro parameter that can be one or multiple values. Is there a
function that would give me the number of values for that parameter? or what
would be a good way to find the number?
Example:
Assume POP is the name of the parameter. If POP was C then the value I would
want to know is 1. If POP was C D DP CS, then the value I would want to
know is 4. POP can be separated by a comma or semicolon, as in C,D,DP,CS .
Thanks
-----------------------------------------------------
Confidentiality Notice: This e-mail transmission
may contain confidential or legally privileged
information that is intended only for the individual
or entity named in the e-mail address. If you are not
the intended recipient, you are hereby notified that
any disclosure, copying, distribution, or reliance
upon the contents of this e-mail is strictly prohibited.
If you have received this e-mail transmission in error,
please reply to the sender, so that we can arrange
for proper delivery, and then please delete the message
from your inbox. Thank you.
/*****************************************************************/
/* PROGRAM: ARGCT.SAS */
/* TYPE: MACRO */
/* LIBRARY: M:\MACROS */
/* PROJECT: ALL */
/* PROTOCOL: ALL */
/* PURPOSE: DETERMINE NUMBER OF ARGUMENTS IN A MACRO PARAMETER. */
/* AUTHOR: M. WALEGA */
/* DATE: 7/21/97 */
/* REVISONS: */
/*****************************************************************/
/*** MACRO PARAMETERS
ARGMNT PARAMETER THAT CONTAINS THE MACRO ARGUMENTS.
DELIM DELIMITER FOR THE ARGUMENTS (DEFAULT IS A SPACE)
SAMPLE CALL:
%let str = age sex weight height;
%let numarg = %argct(&STR);
results in a value of 4 for &NUMARG
***/
%macro argct(argmnt,delim=);
%if "&DELIM" ne "" %then
%let dlm = ,&DELIM;
%else %let dlm = ;
%if "&ARGMNT" = "" %then 0;
%else %do;
%let argct = 1;
%do %while("%scan(&ARGMNT,&ARGCT+1&DLM)" ne "");
%let argct = %eval(&ARGCT+1);
%end;
&ARGCT
%end;
%mend;