Date: Fri, 20 Nov 2009 08:36:41 -0800
Reply-To: Dirk Nachbar <dirknbr@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dirk Nachbar <dirknbr@GOOGLEMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Macro question: How to created macro variables from a macro
Content-Type: text/plain; charset=ISO-8859-1
On Nov 20, 3:49 pm, Kevin.F.Spr...@DARTMOUTH.EDU ("Kevin F. Spratt")
wrote:
> The macro below works when I don't use the CI variable and instead
> hard code the
> size of the confidence interval.
>
> When I add the CI= option in the macro it doesn't work, I'm guessing
> for a number
> of reasons, such as attempting to create a variable outside of a datastep and,
> perhaps, treating said variables as both a number and as text.
>
> Any help appreciated.
>
> Thanks.
>
> %MACRO UNIVAR(DATA=ONE, VAR=EXP,
> CI=95);
>
> %LET LBCI=(100 -
> &CI)/2 ;
>
> %LET UBCI= &CI +
> &LBCI ;
>
> PROC UNIVARIATE DATA=WORK.&DATA
> NOPRINT;
>
> CLASS S
> ;
>
> VAR
> &VAR;
>
> OUTPUT OUT=FREQ_&VAR MEAN=&VAR PCTLPTS = &LBCI &UBCI
> PCTLPRE=CI;
>
> RUN;
>
> DATA WORK.FREQ_&VAR ;SET
> WORK.FREQ_&VAR;
>
> STATISTIC ="&VAR"
> ;
>
> SCORE =&VAR ;
>
> LB95PCTCI =CI"&LBCI";
>
> UB95PCTCI =CI"&UBCI";
>
> KEEP S STATISTIC SCORE LB95PCTCI
> UB95PCTCI ;
>
> RUN;
>
> %MEND UNIVAR;
>
> ______________________________________________________________________
>
> Kevin F. Spratt, Ph.D.
> Department of Orthopaedic Surgery
> Dartmouth Medical School
> One Medical Center Drive
> DHMC
> Lebanon, NH USA 03756
> (603) 653-6012 (voice)
> (603) 653-6013 (fax)
> Kevin.F.Spr...@Dartmouth.Edu (e-mail)
> _______________________________________________________________________
yes you need to do this %LET LBCI=%eval((100 - &CI)/2 ) ;
Dirk
|