Good morning. I've inherited code from long ago that suddenly has stopped running. I can't seem to figure out what's happened here. The issue, as noted in the log is "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." However, this doesn't appear to be the only error. I'm not good with macros so I can't seem to figure this one out.
One thing I had thought of, based on other posts, was the format of the data in &report_date_txt. This date is 03/2002 and so has a special character.
As I said, I'm not good with macros so I don't really understand what's potentially happening here. Can anyone offer some suggestions?
I believe the first section is from the compiler and the second is from the actual run.
Thank you very much.
To enter a constant or literal value you use quotes. If the value is not a character string the the character(s) immediately after the closing quote tell SAS what type of value it is. So D means DATE and T means TIME and there are others. The warning is because you have a P immediately after the quote in the second line below, but not in the first line.
put """OC"""','"""&report_date_txt."""','"""PrisonerHousedBydoC"""',' prisoners_housed_by_doc ',';
put """OC"""','"""&report_date_txt."""','"""PrisonersOutsourced"""','prisoners_outsourced ',';
You should probably just go ahead and insert spaces around all of the items in your PUT statements, that should solve the issue.
put """OC""" ',' """&report_date_txt.""" ',' """PrisonerHousedBydoC""" ',' prisoners_housed_by_doc ',';
put """OC""" ',' """&report_date_txt.""" ',' """PrisonersOutsourced""" ',' prisoners_outsourced ',';
To enter a constant or literal value you use quotes. If the value is not a character string the the character(s) immediately after the closing quote tell SAS what type of value it is. So D means DATE and T means TIME and there are others. The warning is because you have a P immediately after the quote in the second line below, but not in the first line.
put """OC"""','"""&report_date_txt."""','"""PrisonerHousedBydoC"""',' prisoners_housed_by_doc ',';
put """OC"""','"""&report_date_txt."""','"""PrisonersOutsourced"""','prisoners_outsourced ',';
You should probably just go ahead and insert spaces around all of the items in your PUT statements, that should solve the issue.
put """OC""" ',' """&report_date_txt.""" ',' """PrisonerHousedBydoC""" ',' prisoners_housed_by_doc ',';
put """OC""" ',' """&report_date_txt.""" ',' """PrisonersOutsourced""" ',' prisoners_outsourced ',';
Please note that the word "error" does not appear anywhere in that warning.
I would be much more concerned about the conversion of numeric to character values in the first note. The rules for converting such numeric values may not always be what you want.
I don't believe I have ever seen code with as many quotes around a single value as your code uses.
I am sure there must be some reason but seeing code like:
put """OC"""','"""&report_date_txt."""','"""OperationalCapacity"""',' operational_capacity ',';
makes me cringe.
Define a sufficiently long variable to hold a complete line of text, and build each line by using the QUOTE and CATX functions; then PUT that single variable. This will reduce the size and complexity of your code greatly.
Thank you very much for the helpful suggestion. I really wish I was better at this 🙂
@Jeff_DOC wrote:
Thank you very much for the helpful suggestion. I really wish I was better at this 🙂
Don't feel bad. I've been programming off and on in different languages since 1978 and still learning things. Sometimes relearning.
Does the target system really needs the extra quotes? Most systems (and the actual standard for delimited files) does not need those extra quotes around the values of the first three fields in the comma delimited file.
You could probably make the code much easier to maintain if you just made the names (or labels) of the variables match the values you want to write. So something like this instead:
data _null_;
* Define variable names and labels ;
label
OPERATIONAL_CAPACITY ="OperationalCapacity"
PRISONERS_HOUSED_BY_DOC ="PrisonerHousedBydoC"
PRISONERS_OUTSOURCED ="PrisonersOutsourced"
MALE_SECURITY_STAFF ="MaleSecurityStaff"
FEMALE_SECURITY_STAFF ="FemaleSecurityStaff"
AGENCY_FACILITY_STAFF ="InstitutionalStaff"
zero1 ="Jails"
zero2 ="CommunityBasedCorrections"
one1 ="Prisons"
zero3 ="CivilCommitments"
zero4 ="Probation"
zero5 ="Parole"
zero6 ="Juvenile"
zero7 ="ParoleBoard"
AVG_SENT_LENGTH ="AvgLengthOfSentence"
AVG_LOS ="AvgLengthOfStaySentencedOffenders"
AVG_LOS_PRETRIAL ="AvgLengthOfStayPretrial"
LESS_ONE_YEAR ="LessThan1Year"
ONE_TO_THREE ="1To3Years"
THREE_TO_FIVE ="3To5Years"
FIVE_TO_TEN ="5To10Years"
TEN_TO_TWENTY ="10To20Years"
TWENTY_TO_FORTY ="20To40Years"
OVER_FORTY ="MoreThan40Years"
LIFE ="LifeWithParole"
LIFE_NO_PAROLE ="LifeWithoutParole"
DEATH ="Death"
PART_I_VIOLENT ="PartIViolentCrime"
OTHER_VIOLENT ="OtherViolentCrime"
PROPERTY ="PropertyCrime"
DRUG ="DrugCrime"
PRE_TRIAL ="PretrialNonConvicted"
OTHER_PUBLIC_ORDER ="OtherPublicOrderCrime"
OTHER ="OtherCrime"
AVERAGE_AGE ="AverageAge"
MALE ="Male"
FEMALE ="Female"
WHITE ="White"
BLACK ="BlackOrAfricanAmerican"
zero8 ="NativeHawaiianOrPacificIslander"
NATIVE_AMERICAN_ALASKAN_NATIVE ="NativeAmericanAlaskanNative"
HISPANIC ="HispanicOrLatino"
ASIAN ="Asian"
zero9 ="Other"
UNKNOWN ="UnknownMissing"
NON_CITIZENS ="NonCitizens"
NEW_CONVICTION ="NewConviction"
TECH_NEW_SENTENCE ="TechnicalViolationWithNewSentence"
TECH_NO_NEW_SENTENCE ="TechnicalViolationWithNoNewSentence"
zero10 ="PretrialAdmission"
;
array all OPERATIONAL_CAPACITY -- zero10 ;
* Set values of zero and one variables ;
one1=1;
array zero [10 ] zero1-zero10 (10 *0);
retain zero1-zero10;
set org_char11;
file "\\temp\org_char&report_date_num..txt" dsd ;
* Write one line per variable ;
length col1-col5 $50 ;
col1="OC";
col2="&report_date_txt.";
col5=' ';
do index=1 to dim(all);
col3=vlabel(all[index]);
col4=vvalue(all[index]);
put col1 ~ col2 ~ col3 ~ col4 col5 ;
end;
run;
The ~ modifier in the PUT statement is what is adding the quotes. The empty COL5 is what is adding the trailing comma.
I so wish this forum had a "thanks for the helpful efficiency suggestions" button.
Thank you very much for the advice!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.