LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 16 Feb 2004 10:49:44 -0500
Reply-To:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject:   Re: macro errors
Comments:   To: Jamil Ibrahim <jibrahim@IR.UMSMED.EDU>

On Mon, 16 Feb 2004 08:54:42 -0600, Jamil Ibrahim <jibrahim@IR.UMSMED.EDU> wrote:

>Hi sas users: what is wrong with this macros: > >OPTIONS NODATE NONUMBER; DM "LOG;CLEAR;OUT;CLEAR;"; > >%let CSA=HYP; >%MACRO csa; > %if &CSA=HYPE %THEN %DO; > %LET X=19; > %LET FA= %STR(SUM (OF Q1-Q7)); %LET AA=7; >%LET FB= %STR(SUM (OF Q8-Q14)); %LET BB=7; >%LET FC= %STR(SUM (OF Q15-Q19)); %LET CC=5; > %END; %MEND CSA; %CSA; > > > >proc format; value yn 1='Yes' 0,.='No'; > %let path=%str(c:\bubble\myforms\som\osce\); > >DATA DESC; >INFILE "&path.Thyp2.txt" LRECL=200 MISSOVER PAD; >%MACRO GOGO; %DO I=1 %TO &X; > INPUT @1 %str(D&i) $char100. / @1 %str(C&i) $char100. ; > %END; %MEND GOGO; %GOGO; RUN; > > > > > >data DAT; >INFILE "&path.hyp.dat" LRECL=200 MISSOVER PAD; >INPUT @1 (q1-q&X) (1.) @37 S_ID $CHAR4. @42 P_ID $CHAR4. @47 rot >$CHAR1. @49 group $CHAR1. @51 date MMDDYY. @58 S_NAME $CHAR17. >@75 P_NAME $CHAR17. ; >FA="&FA"; fApct= round(((fA/&AA)*100),2); > FB="&FB" ;fBpct= round(((fB/&BB)*100),2); > FC="&FC" ; fCpct= round(((fC/&CC)*100),2); >tot=sum (of q1-q&x); totpct=round(((tot/&x)*100),2);MISS=&X-TOT; > >********NEXT LINE MERGES ONE FILE WITH ONE OBS WITH MULTIPLE VARS IN >ANOTHER FILE WITH NULTIPLE VARS AND MULTIPLE OBS; >DATA C; IF _N_ = 1 THEN SET DESC; SET DAT; RUN; > >PROC SORT; BY S_ID P_ID ROT GROUP; RUN; >DATA _NULL_; SET C END=EOF; BY S_ID ;; >format q1-q&x yn. DATE MMDDYY. ; >FILE PRINT HEADER=HDR; >IF FIRST.S_ID THEN PUT _PAGE_; > >%MACRO PRINTIT; > %DO I=1 %TO &X; > IF %STR(D&I) = D8 THEN PUT / > @ 5 "your raw score on this part =" FA " " fApct "%" /; > else IF %STR(D&I) = d15 THEN PUT / > @ 5 "your raw score on this part =" FB " " fBpct "%" /; > > > IF %STR(C&i) NE " " AND %str(D&i) NE " " > THEN DO; PUT @10 %str(D&i) $char80. / > @1 Q&I @10 %str(C&i) $char80.; END; > ELSE DO; PUT @1 Q&I @10 %str(D&i) $char80. ; END; > %END; >if last.s_id AND MISS GT 0 THEN DO; > PUT / @ 5 "your raw score on this part =" FC " " fCpct "%" / > @5 "Your overall score on this case is= " > "(" tot "OF " "&X" ") " totpct "%" > " MISSED ITEMS= " MISS /; END; >ELSE if last.s_id AND MISS =0 THEN DO; > PUT / @ 5 "your raw score on this part =" FC " " fCpct "%" / > @5 "Your overall score on this case is= " > "(" tot "OF " "&X" ") " totpct "%" /; END; > > RETURN; > %MEND PRINTIT; %PRINTIT; > >RETURN; > >HDR: >title1 "SCHOOL OF MEDICINE - CLINICAL SKILLS ASSESSMENT - HYPERTENSION >CASE EVALUATION REPORT"; >PUT / @1 "STUDENT: " s_ID " " s_NAME >" PATIENTS: " P_ID " " P_NAME >" ROTATION: " ROT >" GROUP:= " GROUP >" DATE: " DATE ; >PUT @1 115*'-' / >@1 "Performed Item Description" / @1 115*'-' / ; >RETURN; RUN; QUIT;

Hi, Jamil,

As somebody in a movie said, "Help me to help you!" What you want to do, what you see on the log, all of these pieces are critical in putting the puzzle together. :-)

Having said that, I see at the top, you assign the macro variable, CSA to be HYP not HYPE. Also you %let several macro variables within the macro CSA, so that they may become local to the macro and not available outside, unless you make them global in some way.

It seems that you are reading hyp.dat file so I would first see if I can make the data step dat work without any error -- not using any macros at all. Once you can get that done, parametrizing it with macro variables should be easy. As Ian once said, "One step at a time."

Cheers, Chang


Back to: Top of message | Previous page | Main SAS-L page