From: toby dunn on 26 Jul 2007 11:01 John , Throw us a bone and show the error from the log. Toby Dunn If anything simply cannot go wrong, it will anyway. Murphys Law #2. The buddy system is essential to your survival; it gives the enemy somebody else to shoot at. Murphys Law # Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch to be sure. Murphys Law #9 From: John Edward <entry_mid_level_sas(a)YAHOO.COM> Reply-To: John Edward <entry_mid_level_sas(a)YAHOO.COM> To: SAS-L(a)LISTSERV.UGA.EDU Subject: A simple MACRO question: Date: Thu, 26 Jul 2007 10:57:29 -0400 I have the following code: %MACRO select(datas = ); Proc sort data = in_08.&datas out = datas_08; By subjid; run; Proc sort data = in_15.&datas out = datas_15; By subjid; run; data &datas; set datas_08 datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN; Now I want to use the same macro for every "datas" like as below. But giving me error: %MACRO select(datas = ); Proc sort data = in_08.&datas out = &datas_08; By subjid; run; Proc sort data = in_15.&datas out = &datas_15; By subjid; run; data &datas; set &datas_08 &datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN; _________________________________________________________________ http://newlivehotmail.com
From: Bob_Abelson on 26 Jul 2007 11:13 The problem is that the second way, &datas_08 and &datas_15 are new macro variables that you haven't defined. Try using &datas._08 and &datas._15 instead, and the macro will create datasets named ae_08 and ae_15, which I'm guessing is what you want. Bob Abelson HGSI 240 314 4400 x1374 bob_abelson(a)hgsi.com "John Edward" <entry_mid_level_sas(a)YAHOO.COM> Sent by: "SAS(r) Discussion" <SAS-L(a)LISTSERV.UGA.EDU> 07/26/2007 10:57 AM Please respond to "John Edward" <entry_mid_level_sas(a)YAHOO.COM> To SAS-L(a)LISTSERV.UGA.EDU cc Subject A simple MACRO question: I have the following code: %MACRO select(datas = ); Proc sort data = in_08.&datas out = datas_08; By subjid; run; Proc sort data = in_15.&datas out = datas_15; By subjid; run; data &datas; set datas_08 datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN; Now I want to use the same macro for every "datas" like as below. But giving me error: %MACRO select(datas = ); Proc sort data = in_08.&datas out = &datas_08; By subjid; run; Proc sort data = in_15.&datas out = &datas_15; By subjid; run; data &datas; set &datas_08 &datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN;
From: Douglas Martin on 26 Jul 2007 11:24 The answer is as a previous respondent said - you need a period between &datas and _08, i.e. &datas._08. To elaborate - a single period following a macro variable name indicates the end of that macro variable name and will not appear in the macro expansion. While you don't need it in what you are doing here, for future reference if you really do want an actual period following the expansion of a macro variable, use two periods, e.g. &file..txt On Thu, 26 Jul 2007 11:15:05 -0400, John Edward <entry_mid_level_sas(a)YAHOO.COM> wrote: >The error is as belowas tobby asked for: > .... -------- > 202 >1 ! = &datas_15; By subjid; run; data &datas; set &datas_08 >&datas_15; By subjid; run; >WARNING: Apparent symbolic reference DATAS_08 not resolved. > >ERROR 22-322: Expecting a name. > ..
From: Frank Boggasch on 26 Jul 2007 11:16 since an underscore is a valid character in a macro variable name, you have to place a period '.' where the macro variables ends, e.g. out = &datas._08; otherwise SAS will try to resolve the macro variable &datas_08, which does not exist. -Frank -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L(a)LISTSERV.UGA.EDU]On Behalf Of John Edward Sent: Donnerstag, 26. Juli 2007 16:57 To: SAS-L(a)LISTSERV.UGA.EDU Subject: A simple MACRO question: I have the following code: %MACRO select(datas = ); Proc sort data = in_08.&datas out = datas_08; By subjid; run; Proc sort data = in_15.&datas out = datas_15; By subjid; run; data &datas; set datas_08 datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN; Now I want to use the same macro for every "datas" like as below. But giving me error: %MACRO select(datas = ); Proc sort data = in_08.&datas out = &datas_08; By subjid; run; Proc sort data = in_15.&datas out = &datas_15; By subjid; run; data &datas; set &datas_08 &datas_15; By subjid; run; %MEND select; %SELECT(datas = ae) RUN;
From: John Edward on 26 Jul 2007 11:15
The error is as belowas tobby asked for: 472 %MACRO select(datas = ); 473 474 Proc sort data = in_08.&datas 475 out = &datas_08; 476 By subjid; 477 run; 478 479 Proc sort data = in_15.&datas 480 out = &datas_15; 481 By subjid; 482 run; 483 484 data &datas; 485 set &datas_08 486 &datas_15; 487 By subjid; 488 run; 489 490 %MEND select; 491 492 %SELECT(datas = trt) NOTE: Line generated by the invoked macro "SELECT". 1 Proc sort data = in_08.&datas out = &datas_08; By subjid; run; Proc sort data = in_15.&datas out - 22 -------- 202 1 ! = &datas_15; By subjid; run; data &datas; set &datas_08 &datas_15; By subjid; run; WARNING: Apparent symbolic reference DATAS_08 not resolved. ERROR 22-322: Expecting a name. ERROR 202-322: The option or parameter is not recognized and will be ignored. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATAS_08 may be incomplete. When this step was stopped there were 0 observations and 0 variables. WARNING: Data set WORK.DATAS_08 was not replaced because this step was stopped. NOTE: PROCEDURE SORT used: real time 0.01 seconds cpu time 0.00 seconds 22: LINE and COLUMN cannot be determined. NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 22-322: Expecting a name. 202: LINE and COLUMN cannot be determined. NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 202-322: The option or parameter is not recognized and will be ignored. WARNING: Apparent symbolic reference DATAS_15 not resolved. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATAS_15 may be incomplete. When this step was stopped there were 0 observations and 0 variables. WARNING: Data set WORK.DATAS_15 was not replaced because this step was stopped. NOTE: PROCEDURE SORT used: real time 0.01 seconds cpu time 0.00 seconds 22: LINE and COLUMN cannot be determined. NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. 202: LINE and COLUMN cannot be determined. NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 202-322: The option or parameter is not recognized and will be ignored. 22: LINE and COLUMN cannot be determined. NOTE 242-205: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. 202: LINE and COLUMN cannot be determined. NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL may allow recovery of the LINE and COLUMN where the error has occurred. ERROR 202-322: The option or parameter is not recognized and will be ignored. WARNING: Apparent symbolic reference DATAS_08 not resolved. WARNING: Apparent symbolic reference DATAS_15 not resolved. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.TRT may be incomplete. When this step was stopped there were 0 observations and 26 variables. WARNING: Data set WORK.TRT was not replaced because this step was stopped. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.00 seconds 493 RUN; |