LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (January 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 24 Jan 2002 14:07:34 -0500
Reply-To:     Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:     To: "Michael C. Wooten" <mwooten@MAIL.AUBURN.EDU>
From:         Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject:      Re: Macro statement help
Comments: To: SAS-L@LISTSERV.VT.EDU
Content-Type: text/plain; charset="iso-8859-1"

Michael,

Although the code leaves much to be desired from a programming point of view, it worked fine for me as the log shows.

76 %macro newreg; 77 proc means noprint; 78 var X Y; 79 output out = std1 css = csX csY mean = mX mY; 80 81 data slope1; set std1; 82 sl = csY/csX; 83 slope = SQRT(sl); 84 yint = mY-(slope*mX); 85 call symput('yint_a',yint); 86 call symput('slope_b',slope); 87 88 data res; set gopher; 89 pred = &yint_a+(&slope_b*X); 90 residual = Y-pred; 91 res2 = residual**2; 92 93 Proc print; 94 %mend newreg; 95 96 options mprint ; 97 %newreg; MPRINT(NEWREG): proc means noprint; MPRINT(NEWREG): var X Y; MPRINT(NEWREG): output out = std1 css = csX csY mean = mX mY; NOTE: There were 20 observations read from the data set WORK.W. NOTE: The data set WORK.STD1 has 1 observations and 6 variables. NOTE: PROCEDURE MEANS used: real time 0.00 seconds

MPRINT(NEWREG): data slope1; MPRINT(NEWREG): set std1; MPRINT(NEWREG): sl = csY/csX; MPRINT(NEWREG): slope = SQRT(sl); MPRINT(NEWREG): yint = mY-(slope*mX); MPRINT(NEWREG): call symput('yint_a',yint); MPRINT(NEWREG): call symput('slope_b',slope); NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 115:188 115:219 NOTE: There were 1 observations read from the data set WORK.STD1. NOTE: The data set WORK.SLOPE1 has 1 observations and 9 variables. NOTE: DATA statement used: real time 0.00 seconds

MPRINT(NEWREG): data res; MPRINT(NEWREG): set gopher; ERROR: File WORK.GOPHER.DATA does not exist. MPRINT(NEWREG): pred = -0.105785304+(1.0323893847*X); MPRINT(NEWREG): residual = Y-pred; MPRINT(NEWREG): res2 = residual**2;

NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.RES may be incomplete. When this step was stopped there were 0 observations and 5 variables. WARNING: Data set WORK.RES was not replaced because this step was stopped. NOTE: DATA statement used: real time 0.06 seconds

The last step did not work because I failed to supply a data set WORK.GOPHER, not because SAS failed to resolve your macro variables.

Perhaps showing your log with the option MPRINT on will help you or someone on SAS-L to indicate the problem.

IanWhitlock@westat.com

-----Original Message----- From: Michael C. Wooten [mailto:mwooten@MAIL.AUBURN.EDU] Sent: Thursday, January 24, 2002 1:28 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Macro statement help

Hello, I am trying to create a variable within one DATA set and use it repeatedly in another. This should be simple but I cannot get the variable state to transfer between DATA steps. I attempted to use the SYMPUT statement but that seems to be incorrect. The code is below. Any suggestions would be greatly appreciated. Thank you!

%macro newreg; proc means noprint; var X Y; output out = std1 css = csX csY mean = mX mY;

data slope1; set std1; sl = csY/csX; slope = SQRT(sl); yint = mY-(slope*mX); call symput('yint_a',yint); call symput('slope_b',slope);

data res; set gopher; pred = &yint_a+(&slope_b*X); residual = Y-pred; res2 = residual**2;

Proc print; %mend newreg; %newreg;


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