BookmarkSubscribeRSS Feed
jc3992
Pyrite | Level 9

Hello everyone,

 

I would like to ask if I do any wrong to multiple conditions in macro function:

The data set contains the following columns:

Employer Receiver Date Amount City State Zip LastNamePart FirstNamePart

 

The question is:

Write a SAS program that accesses the data in the permanent SAS data set named churchdata.  Subset the data to only contain records with the last name of Church that live in New York State (NY).  Do not assume that all such values are in uppercase.

 

I wonder if I use "If...and...then...do"

Can I solve this one?

Seemed not because in my output,

only Last name contained "Church" be selected,

but the State did not exclude those other than "NY"

 

I wonder if anyone has other thoughts?

Thanks a lot~~

 

options MPRINT;
%let LastNamePart=Church;
%let State=NY;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church(lib=, dsn=,LastNamePart=, State=);
data churchdata;
set"&dirdata/Programs/Week_6/churchdata.sas7bdat";
%if &LastNamePart.=Church 
&State. =NY
%then %do;
%end; 
proc print data=&lib..&dsn.;
run;
%mend;

%church(lib=perm, dsn=churchdata,LastNamePart=Church,State=NY);

LOG:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options MPRINT;
 74         %let LastNamePart=Church;
 75         %let State=NY;
 76         %let dirdata=/folders/myfolders;
 77         libname perm "&dirdata";
 NOTE: Libref PERM refers to the same physical library as WEEK_6.
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 78         run;
 79         %macro church(lib=, dsn=,LastNamePart=, State=);
 80         data churchdata;
 81         set"&dirdata/Programs/Week_6/churchdata.sas7bdat";
 82         %if &LastNamePart.=Church
 83         &State. =NY
 84         %then %do;
 85         %end;
 86         proc print data=&lib..&dsn.;
 87         run;
 88         %mend;
 89         
 90         %church(lib=perm, dsn=churchdata,LastNamePart=Church,State=NY);
 MPRINT(CHURCH):   data churchdata;
 MPRINT(CHURCH):   set"/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 NOTE: Data file _TEMP2.CHURCHDATA.DATA is in a format that is native to another host, or the file encoding does not match the 
       session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce 
       performance.
 
 NOTE: There were 500 observations read from the data set /folders/myfolders/Programs/Week_6/churchdata.sas7bdat.
 NOTE: The data set WORK.CHURCHDATA has 500 observations and 9 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.02 seconds
       cpu time            0.02 seconds
       
 
 MPRINT(CHURCH):   proc print data=perm.churchdata;
 ERROR: File PERM.CHURCHDATA.DATA does not exist.
 MPRINT(CHURCH):   run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 91         
 92         
 93         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 106        
 User: sasdemo
Macro Variables
15 REPLIES 15
Shmuel
Garnet | Level 18

Don't you miss a word in the next statement:

   %if &LastNamePart.=Church  and /* or */  &State. =NY %then %do;

 

jc3992
Pyrite | Level 9

I changed to this.

options MPRINT;
%let LastNamePart=Church;
%let State=NY;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church(lib=, dsn=,LastNamePart=, State=);
data churchdata;
set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
proc sort data=churchdata out=church1;
by &LastNamePart.;
where &State.=NY;
run;
proc print data=church1;
var &LastNamePart. ;
run;
%mend;

%church(lib=perm, dsn=churchdata,LastNamePart=Church,State=NY);

Yes I tried that but did not work.

 

The above code also got errors:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options MPRINT;
 74         %let LastNamePart=Church;
 75         %let State=NY;
 76         %let dirdata=/folders/myfolders;
 77         libname perm "&dirdata";
 NOTE: Libref PERM refers to the same physical library as WEEK_6.
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 78         run;
 79         %macro church(lib=, dsn=,LastNamePart=, State=);
 80         data churchdata;
 81         set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 82         proc sort data=churchdata out=church1;
 83         by &LastNamePart.;
 84         where &State.=NY;
 85         run;
 86         proc print data=church1;
 87         var &LastNamePart. ;
 88         run;
 89         %mend;
 90         
 91         %church(lib=perm, dsn=churchdata,LastNamePart=Church,State=NY);
 MPRINT(CHURCH):   data churchdata;
 MPRINT(CHURCH):   set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 NOTE: Data file _TEMP2.CHURCHDATA.DATA is in a format that is native to another host, or the file encoding does not match the 
       session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce 
       performance.
 
 NOTE: There were 500 observations read from the data set /folders/myfolders/Programs/Week_6/churchdata.sas7bdat.
 NOTE: The data set WORK.CHURCHDATA has 500 observations and 9 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.02 seconds
       cpu time            0.01 seconds
       
 
 MPRINT(CHURCH):   proc sort data=churchdata out=church1;
 MPRINT(CHURCH):   by Church;
 ERROR: Variable CHURCH not found.
 MPRINT(CHURCH):   where NY=NY;
 ERROR: Variable NY is not on file WORK.CHURCHDATA.
 MPRINT(CHURCH):   run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.CHURCH1 may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
 WARNING: Data set WORK.CHURCH1 was not replaced because this step was stopped.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 MPRINT(CHURCH):   proc print data=church1;
 MPRINT(CHURCH):   var Church ;
 ERROR: Variable CHURCH not found.
 MPRINT(CHURCH):   run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 92         
 93         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 106        
Kurt_Bremser
Super User

Quote from your post:

 

"

The question is:

Write a SAS program that accesses the data in the permanent SAS data set named churchdata.  Subset the data to only contain records with the last name of Church that live in New York State (NY).  Do not assume that all such values are in uppercase.

"

 

There's no mention of a macro, so why in $DEITY's name are you making your life unnecessarily hard? This issue is VERY simply solved in data step code only:

%let dirdata=/folders/myfolders;

libname perm "&dirdata./Programs/Week_6";

data churchdata;
set perm.churchdata;
if upcase(lastnamepart) = "CHURCH" and upcase(state) = "NY";
run;

proc print data=churchdata noobs;
run;
jc3992
Pyrite | Level 9

Because for the following questions we have to do macro....:(

Thanks~~

 

Mine is 

options MPRINT;
%let LastNamePart=Church;
%let State=NY;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church(lib=, dsn=,LastNamePart=, State=);
data churchdata;
set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
proc sort data=churchdata out=church1;
by &LastNamePart. &State.;
where &LastNamePart.=Church and &State.=NY;
run;
proc print data=church1;
title;
run;
%mend;

%church(lib=perm, dsn=church1,LastNamePart=Church,State=NY);

still had no idea why it did not work though

but gotta move on to the next~~

(right hand hurts....)

Thanks guys!!

 

LOG:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options MPRINT;
 74         %let LastNamePart=Church;
 75         %let State=NY;
 76         %let dirdata=/folders/myfolders;
 77         libname perm "&dirdata";
 NOTE: Libref PERM refers to the same physical library as WEEK_6.
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 78         run;
 79         %macro church(lib=, dsn=,LastNamePart=, State=);
 80         data churchdata;
 81         set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 82         proc sort data=churchdata out=church1;
 83         by &LastNamePart. &State.;
 84         where &LastNamePart.=Church and &State.=NY;
 85         run;
 86         proc print data=church1;
 87         title;
 88         run;
 89         %mend;
 90         
 91         %church(lib=perm, dsn=church1,LastNamePart=Church,State=NY);
 MPRINT(CHURCH):   data churchdata;
 MPRINT(CHURCH):   set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 NOTE: Data file _TEMP2.CHURCHDATA.DATA is in a format that is native to another host, or the file encoding does not match the 
       session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce 
       performance.
 
 NOTE: There were 500 observations read from the data set /folders/myfolders/Programs/Week_6/churchdata.sas7bdat.
 NOTE: The data set WORK.CHURCHDATA has 500 observations and 9 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.02 seconds
       cpu time            0.01 seconds
       
 
 MPRINT(CHURCH):   proc sort data=churchdata out=church1;
 ERROR: Variable CHURCH not found.
 MPRINT(CHURCH):   by Church NY;
 ERROR: Variable NY not found.
 MPRINT(CHURCH):   where Church=Church and NY=NY;
 ERROR: Variable Church is not on file WORK.CHURCHDATA.
 MPRINT(CHURCH):   run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.CHURCH1 may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
 WARNING: Data set WORK.CHURCH1 was not replaced because this step was stopped.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 MPRINT(CHURCH):   proc print data=church1;
 MPRINT(CHURCH):   title;
 MPRINT(CHURCH):   run;
 NOTE: No variables in data set WORK.CHURCH1.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 92         
 93         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 106        
 User: sasdemo
Procedure Statements

 

Kurt_Bremser
Super User

BEFORE you start putting code into a macro, ALWAYS make sure you have working code without macro interaction.

So you have to start out with the code I gave you. Verify that it works, and then come back with the log if you get errors, or so we can make it dynamic.

jc3992
Pyrite | Level 9
1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         
 74         %let dirdata=/folders/myfolders;
 75         
 76         libname perm "&dirdata./Programs/Week_6";
 NOTE: Libref PERM refers to the same physical library as _TEMP2.
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Programs/Week_6
 77         
 78         data churchdata;
 79         set perm.churchdata;
 NOTE: Data file PERM.CHURCHDATA.DATA is in a format that is native to another host, or the file encoding does not match the session 
       encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce 
       performance.
 80         if upcase(lastnamepart) = "Church" and upcase(state) = "NY";
 81         run;
 
 NOTE: There were 500 observations read from the data set PERM.CHURCHDATA.
 NOTE: The data set WORK.CHURCHDATA has 0 observations and 9 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       cpu time            0.01 seconds
       
 
 82         
 83         proc print data=churchdata noobs;
 84         run;
 
 NOTE: No observations in data set WORK.CHURCHDATA.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 85         if upcase(lastnamepart) = "Church" and upcase(state) = "NY";
            __
            180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 86         run;
 87         
 88         proc print data=churchdata noobs;
 89         run;
 
 NOTE: No observations in data set WORK.CHURCHDATA.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 90         
 91         
 92         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 105        
 User: sasdemo

I got this LOG with your code.

Would you let me know how can I modify it? Thanks~~

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Problem:

Write a SAS program that accesses the data in the permanent SAS data set named churchdata.  Subset the data to only contain records with the last name of Church that live in New York State (NY).  Do not assume that all such values are in uppercase.

 

Solution:

data churchdata;
  set perm.churchdata;
  where scan(church_var,countw(church_var," ")," ")="Church" and state="NY";
run;

I have no idea what the rest of the code you have there is for?

ballardw
Super User
Why use macros? There is no reason to for the stated purpose.
Shmuel
Garnet | Level 18

@jc3992, pay attention:

  macro is just a code generator.

  WHERE statement needs variable name comparaed either to a literal (encosed by quotes) or to a variable name.

 

 

jc3992
Pyrite | Level 9

Why can't this work?

options MPRINT;
%let LastNamePart=Church;
%let State=NY;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church(lib=, dsn=,LastNamePart=, State=);
data churchdata;
set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
proc sort data=churchdata out=church1;
by LastNamePart;
run;
proc print data=church1;
where State="NY";
run;

I did not get error but no result either.

LOG:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         options MPRINT;
 74         %let LastNamePart=Church;
 75         %let State=NY;
 76         %let dirdata=/folders/myfolders;
 77         libname perm "&dirdata";
 NOTE: Libref PERM refers to the same physical library as WEEK_6.
 NOTE: Libref PERM was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders
 78         run;
 79         %macro church(lib=, dsn=,LastNamePart=, State=);
 80         data churchdata;
 81         set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
 82         proc sort data=churchdata out=church1;
 83         by LastNamePart;
 84         run;
 85         proc print data=church1;
 86         where State="NY";
 87         run;
 88         
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 91         ODS HTML CLOSE;
 92         &GRAPHTERM; ;*';*";*/;RUN;QUIT;
 93         QUIT;RUN;
 94         ODS HTML5 (ID=WEB) CLOSE;
 95         
 96         ODS RTF (ID=WEB) CLOSE;
 97         ODS PDF (ID=WEB) CLOSE;
 98         FILENAME _GSFNAME;
 99         DATA _NULL_;
 100        RUN;
 101        OPTIONS VALIDMEMNAME=COMPAT;
 102        OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
 103        
 User: sasdemo
Procedure Options
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"

set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";

" - invalid.  Set syntax = <libname>.<datasetname>.

 

No macro mend statement. 

No call to the macro.

If you pass parameters through, you do not set them up as %let statements.

 

Good programming extra tips:
Additional run; under libname statement not needed, remove.

 

No run; underneath datastep, always finish blocks with the terminator, e.g. run;

 

I would really start by learning Base SAS, this is the programming language, and these are fundamental concepts you are missing here.

Missing . after macro variable invocation, 

jc3992
Pyrite | Level 9

well...but our course has to finish SAS and R in one semester. felt helpless...

options MPRINT;
%let LastNamePart=Church;
%let State=NY;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church(lib=, dsn=,LastNamePart=, State=);
proc sort data churchdata out=church1;
set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
if &LastNamePart.="Church"and &State.="NY" then do;
end;

proc print data=church1;
run;

%mend;

%church(lib=perm, dsn=church1,LastNamePart=Church,State=NY);

I did not get errors with this but no result still...

LOG:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 2          TITLE;
 3          FOOTNOTE;
 4          OPTIONS LOCALE=en_US DFLANG=LOCALE;
 NOTE: The quoted string currently being processed has become more than 262 bytes long.  You might have unbalanced quotation marks.
 5          DATA _NULL_;
 6          RUN;
 7          OPTIONS VALIDVARNAME=V7;
 8          OPTIONS VALIDMEMNAME=COMPAT;
 9          FILENAME _HTMLOUT TEMP;
 10         FILENAME _RTFOUT TEMP ENCODING='UTF-8';
 11         FILENAME _PDFOUT TEMP;
 12         FILENAME _GSFNAME TEMP;
 13         FILENAME _DATAOUT TEMP;
 14         %LET SYSCC=0;
 15         %LET _CLIENTAPP='SAS Studio';
 16         %LET _CLIENTAPPABREV=Studio;
 17         %LET _CLIENTAPPVERSION=3.7;
 18         %LET _CLIENTVERSION=3.7;
 19         %LET _CLIENTMODE=basic;
 20         %LET _SASSERVERNAME=%BQUOTE(localhost);
 21         %LET _SASHOSTNAME=%BQUOTE(localhost);
 22         %LET _SASPROGRAMFILEHOST=%BQUOTE(localhost);
 23         %LET _CLIENTUSERID=%BQUOTE(sasdemo);
 24         %LET _CLIENTUSERNAME=%BQUOTE(sasdemo);
 25         %LET CLIENTMACHINE=%BQUOTE(10.0.2.2);
 26         %LET _CLIENTMACHINE=%BQUOTE(10.0.2.2);
 27         %let SASWORKLOCATION="%sysfunc(getoption(work))/";
 28         FILENAME _CWD '.';
 29         DATA _NULL_;
 30         CALL SYMPUT('_SASWORKINGDIR',PATHNAME('_CWD'));
 31         RUN;
 32         FILENAME _CWD;
 33         
 34         %LET _SASPROGRAMFILE = %NRQUOTE(%NRSTR(/folders/myfolders/Programs/Week_6/ChenJenli_jc3992_Assignment5.sas));
 35         %LET _BASEURL = %BQUOTE(http://localhost:10080/SASStudio/);
 36         %LET _EXECENV=SASStudio;
 
            ______________________________________________________________________________________________________________________
            49
 
 
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 37         DATA _NULL_;
 38         CALL
 38       ! SYMPUT("GRAPHINIT"
                             _
                             49
 38       ! ,"");
 39         CALL
 39       ! SYMPUT("GRAPHTERM"
                             _
                             49
 39       ! ,"");
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 40         RC=TSLVL('GEOCODE','N');
 41         _ERROR_=0;
 42         IF (RC^=' ') THEN DO;
 43         CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;");
                                  ___                                    ________________
                                  49                                     49
 44         CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;");
                                  ___                      ___________________________________
                                  49                       49
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 45         END;
 46         RUN;
 47         DATA _NULL_;
 48         RC=SYSPROD("PRODNUM002"
                                  _
                                  49
 48       ! );
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 49         IF (RC^=1) THEN DO;
 50         CALL
 50       ! SYMPUT("GRAPHINIT"
                             _
                             49
 50       ! ,"");
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 51         CALL SYMPUT("GRAPHTERM","");
 52         END;
 53         RUN;
 54         %LET _DATAOUT_MIME_TYPE=;
 55         %LET _DATAOUT_NAME=;
 56         %LET _DATAOUT_TABLE=;
 57         %LET _DATAOUT_URL=;
 58         %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE;
 59         %LET _SASWS_ = %BQUOTE(/folders/myfolders);
 60         %LET _SASWSTEMP_=%BQUOTE(/folders/myfolders/.sasstudio/.images/858d35bc-a033-414a-85c6-e0d80658f281);
 61         ODS LISTING CLOSE;
 62         ODS AUTONAVIGATE OFF;
 63         ODS GRAPHICS ON;
 64         ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8  FILE=_HTMLOUT (TITLE='Results:
 64       ! ChenJenli_jc3992_Assignment5.sas') STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE'
 64       ! CSS_PREFIX='.ods_858d35bc-a033-414a-85c6-e0d80658f281' BODY_ID='div_858d35bc-a033-414a-85c6-e0d80658f281' );
 NOTE: The quoted string currently being processed has become more than 262 bytes long.  You might have unbalanced quotation marks.
 65         ODS RTF (ID=WEB) STYLE=Rtf FILE=_RTFOUT sasdate;
 66         ODS PDF (ID=WEB) STYLE=Pearl FILE=_PDFOUT;
 67         &GRAPHINIT;
 68         OPTIONS FIRSTOBS=1;
 69         OPTIONS OBS=MAX;
 70         OPTIONS DTRESET DATE NUMBER NOTES;
 71         OPTIONS NOTES STIMER SOURCE NOSYNTAXCHECK;
 72         
 73         options MPRINT;
 74         %let LastNamePart=Church;
 75         %let State=NY;
 76         %let dirdata=/folders/myfolders;
 77         libname perm "&dirdata";
 78         run;
 79         %macro church(lib=, dsn=,LastNamePart=, State=);
 80         data=churchdata out=church1;
 81         set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat"
                                                                       _____________________
                                                                       49
 81       ! ;
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 82         if &LastNamePart.="Church"and &State.="NY" then do;
 83         end;
 84         proc print data=church1;
 85         run;
 86         %mend;
 87         
 88         %church(lib=perm, dsn=church1,LastNamePart=Church,State=NY);
 89         
 90         
 91         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92         ODS HTML CLOSE;
 93         &GRAPHTERM; ;*';*";*/;RUN;QUIT;
 94         QUIT;RUN;
 95         ODS HTML5 (ID=WEB) CLOSE;
 96         
 97         ODS RTF (ID=WEB) CLOSE;
 98         ODS PDF (ID=WEB) CLOSE;
 99         FILENAME _GSFNAME;
 100        DATA _NULL_;
 101        RUN;
 102        OPTIONS VALIDMEMNAME=COMPAT;
 103        OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
 104        
 User: sasdemo
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Even when you start a new session as @Kurt_Bremser has said, which will solve your initial problems, the code you give will not work.  Please refer to my previous post with necessary corrections.

jc3992
Pyrite | Level 9

Hello,

 

I have another related question as below:

Using your macro, print out the first 5 records from the SAS data set you created in (a), but only for the variables date, receiver, and amount. Include appropriate titles in your listing.

 

My code is :

options MPRINT;

%let dirdata=/folders/myfolders;
%let lib=perm "&dirdata";
%let data=churchdata;
%macro p5m3a (lib=,data=, nobs=);
proc print data=&dirdata.&lib..&dsn. (keep=date receiver amount)(obs=5);
run;
%mend p5m3a;

%p5m3a(lib=perm, data=churchdata,nobs=5);

LOG:

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 2          TITLE;
 3          FOOTNOTE;
 4          OPTIONS LOCALE=en_US DFLANG=LOCALE;
 NOTE: The quoted string currently being processed has become more than 262 bytes long.  You might have unbalanced quotation marks.
 5          DATA _NULL_;
 6          RUN;
 7          OPTIONS VALIDVARNAME=V7;
 8          OPTIONS VALIDMEMNAME=COMPAT;
 9          FILENAME _HTMLOUT TEMP;
 10         FILENAME _RTFOUT TEMP ENCODING='UTF-8';
 11         FILENAME _PDFOUT TEMP;
 12         FILENAME _GSFNAME TEMP;
 13         FILENAME _DATAOUT TEMP;
 14         %LET SYSCC=0;
 15         %LET _CLIENTAPP='SAS Studio';
 16         %LET _CLIENTAPPABREV=Studio;
 17         %LET _CLIENTAPPVERSION=3.7;
 18         %LET _CLIENTVERSION=3.7;
 19         %LET _CLIENTMODE=basic;
 20         %LET _SASSERVERNAME=%BQUOTE(localhost);
 21         %LET _SASHOSTNAME=%BQUOTE(localhost);
 22         %LET _SASPROGRAMFILEHOST=%BQUOTE(localhost);
 23         %LET _CLIENTUSERID=%BQUOTE(sasdemo);
 24         %LET _CLIENTUSERNAME=%BQUOTE(sasdemo);
 25         %LET CLIENTMACHINE=%BQUOTE(10.0.2.2);
 26         %LET _CLIENTMACHINE=%BQUOTE(10.0.2.2);
 27         %let SASWORKLOCATION="%sysfunc(getoption(work))/";
 28         FILENAME _CWD '.';
 29         DATA _NULL_;
 30         CALL SYMPUT('_SASWORKINGDIR',PATHNAME('_CWD'));
 31         RUN;
 32         FILENAME _CWD;
 33         
 34         %LET _SASPROGRAMFILE = %NRQUOTE(%NRSTR(/folders/myfolders/Programs/Week_6/ChenJenli_jc3992_Assignment5.sas));
 35         %LET _BASEURL = %BQUOTE(http://localhost:10080/SASStudio/);
 36         %LET _EXECENV=SASStudio;
 
            ______________________________________________________________________________________________________________________
            49
 
 
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 37         DATA _NULL_;
 38         CALL
 38       ! SYMPUT("GRAPHINIT"
                             _
                             49
 38       ! ,"");
 39         CALL
 39       ! SYMPUT("GRAPHTERM"
                             _
                             49
 39       ! ,"");
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 40         RC=TSLVL('GEOCODE','N');
 41         _ERROR_=0;
 42         IF (RC^=' ') THEN DO;
 43         CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;");
                                  ___                                    ________________
                                  49                                     49
 44         CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;");
                                  ___                      ___________________________________
                                  49                       49
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 45         END;
 46         RUN;
 47         DATA _NULL_;
 48         RC=SYSPROD("PRODNUM002"
                                  _
                                  49
 48       ! );
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 49         IF (RC^=1) THEN DO;
 50         CALL
 50       ! SYMPUT("GRAPHINIT"
                             _
                             49
 50       ! ,"");
 NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
              between a quoted string and the succeeding identifier is recommended.
 
 51         CALL SYMPUT("GRAPHTERM","");
 52         END;
 53         RUN;
 54         %LET _DATAOUT_MIME_TYPE=;
 55         %LET _DATAOUT_NAME=;
 56         %LET _DATAOUT_TABLE=;
 57         %LET _DATAOUT_URL=;
 58         %SYMDEL _DATAOUT_MIME_TYPE _DATAOUT_NAME _DATAOUT_URL _DATAOUT_TABLE;
 59         %LET _SASWS_ = %BQUOTE(/folders/myfolders);
 60         %LET _SASWSTEMP_=%BQUOTE(/folders/myfolders/.sasstudio/.images/1bf2f9c0-63d4-4e15-b723-99d29b4d898e);
 61         ODS LISTING CLOSE;
 62         ODS AUTONAVIGATE OFF;
 63         ODS GRAPHICS ON;
 64         ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8  FILE=_HTMLOUT (TITLE='Results:
 64       ! ChenJenli_jc3992_Assignment5.sas') STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE'
 64       ! CSS_PREFIX='.ods_1bf2f9c0-63d4-4e15-b723-99d29b4d898e' BODY_ID='div_1bf2f9c0-63d4-4e15-b723-99d29b4d898e' );
 NOTE: The quoted string currently being processed has become more than 262 bytes long.  You might have unbalanced quotation marks.
 65         ODS RTF (ID=WEB) STYLE=Rtf FILE=_RTFOUT sasdate;
 66         ODS PDF (ID=WEB) STYLE=Pearl FILE=_PDFOUT;
 67         &GRAPHINIT;
 68         OPTIONS FIRSTOBS=1;
 69         OPTIONS OBS=MAX;
 70         OPTIONS DTRESET DATE NUMBER NOTES;
 71         OPTIONS NOTES STIMER SOURCE NOSYNTAXCHECK;
 72         
 73         
 74         options MPRINT;
 75         
 76         %let dirdata=/folders/myfolders;
 77         %let lib=perm "&dirdata";
 78         %let data=churchdata;
 79         %macro p5m3a (lib=,data=, nobs=);
 80         proc print data=&dirdata.&lib..&dsn. (keep=date receiver amount)(obs=5);
 81         run;
 82         %mend p5m3a;
 83         
 84         %p5m3a(lib=perm, data=churchdata,nobs=5);
 85         
 86         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 87         ODS HTML CLOSE;
 88         &GRAPHTERM; ;*';*";*/;RUN;QUIT;
 89         QUIT;RUN;
 90         ODS HTML5 (ID=WEB) CLOSE;
 91         
 92         ODS RTF (ID=WEB) CLOSE;
 93         ODS PDF (ID=WEB) CLOSE;
 94         FILENAME _GSFNAME;
 95         DATA _NULL_;
 96         RUN;
 97         OPTIONS VALIDMEMNAME=COMPAT;
 98         OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
 99         
 User: sasdemo
Macro Statements

Any help would be highly appreciated!

Thanks~

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 1382 views
  • 6 likes
  • 5 in conversation