Hello everyone,
My code is as below:
data churchdata;
set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat";
if upcase(LastNamePart) = "Church" and upcase(state) = "NY";
run;
proc print data=churchdata noobs;
run;
I got no errors nor any output.
Any help would be appreciated. Thank~
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/b59f1c47-d5c4-49d1-b05b-75c5e247d9ab); 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_b59f1c47-d5c4-49d1-b05b-75c5e247d9ab' BODY_ID='div_b59f1c47-d5c4-49d1-b05b-75c5e247d9ab' ); 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; 64 ODS HTML5 (ID=WEB) DEVICE=PNG GPATH="&_SASWSTEMP_" ENCODING=utf8 FILE=_HTMLOUT (TITLE='Results: ________________________________________________ 49 64 ! ChenJenli_jc3992_Assignment5.sas') STYLE=Htmlblue OPTIONS(BITMAP_MODE='INLINE' OUTLINE='ON' SVG_MODE='INLINE' 64 ! CSS_PREFIX='.ods_b59f1c47-d5c4-49d1-b05b-75c5e247d9ab' BODY_ID='div_b59f1c47-d5c4-49d1-b05b-75c5e247d9ab' ); 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. 70 OPTIONS DTRESET DATE NUMBER NOTES; 71 OPTIONS NOTES STIMER SOURCE NOSYNTAXCHECK; 72 73 data churchdata; 74 set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat" _____________________________ 49 74 ! ; 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. 75 if upcase(LastNamePart) = "Church" and upcase(state) = "NY"; 76 run; 77 78 proc print data=churchdata noobs; 79 run; 80 81 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 82 ODS HTML CLOSE; 83 &GRAPHTERM; ;*';*";*/;RUN;QUIT; 84 QUIT;RUN; 85 ODS HTML5 (ID=WEB) CLOSE; 86 87 ODS RTF (ID=WEB) CLOSE; 88 ODS PDF (ID=WEB) CLOSE; 89 FILENAME _GSFNAME; 90 DATA _NULL_; 91 RUN; 92 OPTIONS VALIDMEMNAME=COMPAT; 93 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK; 94 User: sasdemo Macro Variables
Time for a cup of coffee.
You didn't really expect that upcase(LastNamePart) could ever equal "Church" did you?
I don't really understand...
Is that because of the data type?
I came back to check the data set,
There are surname which is "CHURCH"
so was it because of the Capital letter?
Also,
I have this code:
%let lname=Churchhill;
%let state=VA;
options MPRINT;
%let dirdata=/folders/myfolders;
libname perm "&dirdata";
run;
%macro church2(lname=, state=);
data churchdata;
set churchdata"&dirdata";
if &lname.=Churchhill and &state.=VA then do;
call symput('Churchhill',&lname.);
call symput('VA',&state.);
end;
title "The donors with surname &lname and from the state &state";
proc print data=churchdata;
run;
title;
%mend church2;
%church2(lname=Churchhill,state=VA);
Ask us to modify the earlier code (LastNamePart=CHURCH and State is NY to :
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 2 TITLE; 3 FOOTNOTE; 4 OPTIONS LOCALE=en_US DFLANG=LOCALE; 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; 37 DATA _NULL_; 38 CALL SYMPUT("GRAPHINIT",""); 39 CALL SYMPUT("GRAPHTERM",""); 40 RC=TSLVL('GEOCODE','N'); 41 _ERROR_=0; 42 IF (RC^=' ') THEN DO; 43 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;"); 44 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;"); 45 END; 46 RUN; 47 DATA _NULL_; 48 RC=SYSPROD("PRODNUM002"); 49 IF (RC^=1) THEN DO; 50 CALL SYMPUT("GRAPHINIT",""); 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/878f0262-510f-4d7f-8d0b-bf7a5d005929); 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_878f0262-510f-4d7f-8d0b-bf7a5d005929' BODY_ID='div_878f0262-510f-4d7f-8d0b-bf7a5d005929' ); 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 %let lname=Churchhill; 74 %let state=VA; 75 76 options MPRINT; 77 78 %let dirdata=/folders/myfolders; 79 libname perm "&dirdata"; 80 run; 81 %macro church2(lname=, state=); 82 data churchdata; 83 set churchdata"&dirdata"; 84 if &lname.=Churchhill and &state.=VA then do; 85 call symput('Churchhill',&lname.); 86 call symput('VA',&state.); 87 end; 88 title "The donors with surname &lname and from the state &state"; 89 proc print data=churchdata; 90 run; 91 title; 92 %mend church2; 93 94 %church2(lname=Churchhill,state=VA); 95 96 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 97 ODS HTML CLOSE; 98 &GRAPHTERM; ;*';*";*/;RUN;QUIT; 99 QUIT;RUN; 100 ODS HTML5 (ID=WEB) CLOSE; 101 102 ODS RTF (ID=WEB) CLOSE; 103 ODS PDF (ID=WEB) CLOSE; 104 FILENAME _GSFNAME; 105 DATA _NULL_; 106 RUN; 107 OPTIONS VALIDMEMNAME=COMPAT; 108 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK; 109 User: sasdemo DATA Step Statements
So the real problem is that you are using UPCASE without really knowing what it does. Here's a program you can use to test:
data have;
input original $;
upper = upcase(original);
cards;
Fred
bob
Church
AmY
run;
proc print;
run;
input Employer $ Receiver $ Date mmddyy10. Amount COMMA9. City $ Sate $ Zip LastNamePart $ FirstNamePart $;
Like this?
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 2 TITLE; 3 FOOTNOTE; 4 OPTIONS LOCALE=en_US DFLANG=LOCALE; 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; 37 DATA _NULL_; 38 CALL SYMPUT("GRAPHINIT",""); 39 CALL SYMPUT("GRAPHTERM",""); 40 RC=TSLVL('GEOCODE','N'); 41 _ERROR_=0; 42 IF (RC^=' ') THEN DO; 43 CALL SYMPUT("GRAPHINIT","GOPTIONS RESET=ALL GSFNAME=_GSFNAME;"); 44 CALL SYMPUT("GRAPHTERM","GOPTIONS NOACCESSIBLE;"); 45 END; 46 RUN; 47 DATA _NULL_; 48 RC=SYSPROD("PRODNUM002"); 49 IF (RC^=1) THEN DO; 50 CALL SYMPUT("GRAPHINIT",""); 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/4e483ce2-cce2-4814-ad43-364ce5bf63bb); 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_4e483ce2-cce2-4814-ad43-364ce5bf63bb' BODY_ID='div_4e483ce2-cce2-4814-ad43-364ce5bf63bb' ); 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 data churchdata; 74 set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat"; 75 input Employer $ Receiver $ Date mmddyy10. Amount COMMA9. City $ Sate $ Zip LastNamePart $ FirstNamePart $; 76 if upcase(LastNamePart) = "Church" and upcase(state) = "NY"; 77 run; 78 79 proc print data=churchdata; 80 run; 81 82 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 83 ODS HTML CLOSE; 84 &GRAPHTERM; ;*';*";*/;RUN;QUIT; 85 QUIT;RUN; 86 ODS HTML5 (ID=WEB) CLOSE; 87 88 ODS RTF (ID=WEB) CLOSE; 89 ODS PDF (ID=WEB) CLOSE; 90 FILENAME _GSFNAME; 91 DATA _NULL_; 92 RUN; 93 OPTIONS VALIDMEMNAME=COMPAT; 94 OPTIONS NOTES STIMER SOURCE SYNTAXCHECK; 95 User: sasdemo DATA Step Statements
I'll only be repeating what others have told you.
You initially submitted the following code:
data churchdata; set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat"; if upcase(LastNamePart) = "Church" and upcase(state) = "NY"; run; proc print data=churchdata noobs; run;
The statement in that code:
if upcase(LastNamePart) = "Church" and upcase(state) = "NY";
Two things are happening with that statement. The IF part tells SAS to only select records that meet the two conditions.
The use of the upcase function tells sas to check the values of the two fields after those values have been altered to in in upper case. Thus, if the value were church and ny, it would be checking to only select those records where CHURCH eq "Church" and NY eq "NY".
No problem with the state part, but CHURCH doesn't equal Church.
Also, there's a problem with your set statement: it should have been:
set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat";
You should have submitted:
data churchdata; set "/folders/myfolders/Programs/Week_6/churchdata.sas7bdat"; if upcase(LastNamePart) = "CHURCH" and upcase(state) = "NY"; run; proc print data=churchdata noobs; run;
Art, CEO, AnalystFinder.com
Note: updated my response to include the errors I noticed on the set statement. The location didn't start with a / and sas7bdat was misspelled as sas9dbat
@jc3992 wrote:
Hello everyone,
My code is as below:
data churchdata; set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat"; if upcase(LastNamePart) = "Church" and upcase(state) = "NY"; run; proc print data=churchdata noobs; run;
I got no errors nor any output.
Any help would be appreciated. Thank~
LOG:
Please learn to use a proper SET statement with something like
data want;
set lib.churchdata.
...
When you use
set "folders/myfolders/Programs/Week_6/churchdata.sas7dbat";
the set statement used with a literal path/filename makes SAS create and assign a temporary library and with all of the code SAS studio generates in that case things may get ugly.
The warning messages you are getting like this:
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
are likely happening because somewhere you have managed to get the compiler confused about what role a given quote is supposed to be.
And since that log has basically nothing to do with the code supposedly submitted it is hard to diagnose.
I see. Thanks~~
I just thought that was the safest way coz I am very familiar with that...
After three days with SAS,
I finally can rest a bit...>"<
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.