This is to fit standard code to my data with modifications. It works fine out of macro. But it warns as below when i throw the hard code into the macro. And it takes forever. Run never ends. It probably would end eventually had I waited longer. I cancelled submitted statements when it's beyond 20 min.
NOTE: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation marks.
proc import datafile="...\icd.csv" out=icd_10 dbms=csv replace; getnames=yes; run;
data code_list(rename=x=icd); set icd_10;
format x $10.;
icd10=compress(icd10,'.');
icd_10_original=icd10;
x="[*]"||icd10;
run;
proc sql noprint;
select icd
into :codes separated by '|'
from code_list;
quit;
%put &codes;
options compress=yes;
%let x=:Item_1 - :Item_5;
/*****************************************************************************************************************/;
libname read_in "...";
libname read_op "...";
libname in_iden "...";
%macro loop(case);
%global case1;
%let case1=&case;
%if &case=Other %then %let condition = &codes;
proc datasets noprint;
delete all_&class._other;
run;
%do year = 2015 %to 2017;
%if &year >= 2015 %then
%do;
libname read_in "...";
%if &class=Inside %then %let file=&class._s_;
%else;
%if &class=Outside %then %let file=&class._s_prime_;
%end;
data temp(compress=yes); set read_in.&file&year(where=(patient_state="NY" and substr(left(Admission_Start_Care_Date),1,4)="2015"));
icd_code = catx('*','*',Primary_Item, of Item:);
if prxmatch("m/&condition/oi",icd_code) > 0;
source="Inside";
run;
proc append base=all_&class._other(compress=yes) data=temp force;
run;
%end;
%mend loop;
%let class=Inside;
%loop(Other);
%let class=Outside;
%loop(Other);
Any hints are appreciated.
Thank you very much in advance.
Errors start on Page 7 of the log, when year=2015.
Why is that step failing?
data temp(compress=yes);
set read_in.&file&year(where=(patient_state="NY" and substr(left(Admission_Start_Care_Date),1,4)="2015"));
icd_code = catx('*','*',Primary_Item, of Item:);
if prxmatch("m/&condition/oi",icd_code) > 0;
source="Inside";
run;
I didn't see any unbalanced quotes. Suggestion: save your code, close then reopen a new SAS session, submit: options mprint mlogic symbolgen;, then run your code and, if you still get an error, post your log.
Art, CEO, AnalystFinder.com
Agree with @art297, please post the log.
But please also post a sample of the CSV file you are importing.
Plus I don't see any macro logic if the input data set is empty - could it sometimes be? Or could the headings (and therefore the field names be incorrect) resulting in an empty codes macro variable?
How long was the result of your %put of the Codes variable?
I'm not sure just how many ICD-10 codes there are but I'm pretty sure that concatenating even a small percentage will generate a string much longer than the 260 or so that triggers that warning.
Without following all of your steps where you turned hard code into a macro it is hard to guess where the long run time would come from.
Since this is apparently a look up it may be that an sql join or hash look up might be a better choice. You might be able to use your code_list data set more directly.
Hi guys,
Thanks for getting back to me.
Attached SAS log and %put code file. The code was just run and I haven't looked at the log yet. Will do now. Please also let me know how this guy "options mprint mlogic symbolgen;" made this difference
PS:
ICD-10 code list consisted of 298 codes where half of these are icd-9 thus numeric whereas half of them icd-10 thus characteristic.
Haven't looked at your log, yet, but those options simply provide extra feedback regarding the entire process. They are invaluable in discovering where things may have gone wrong.
Art, CEO, AnalystFinder.com
SAS log is attached here. Because it's too long to copy and paste in here. I noticed libname was not correctly used as defined. No idea how it happened. What else am I missing here? Million thanks.
Errors start on Page 7 of the log, when year=2015.
Why is that step failing?
data temp(compress=yes);
set read_in.&file&year(where=(patient_state="NY" and substr(left(Admission_Start_Care_Date),1,4)="2015"));
icd_code = catx('*','*',Primary_Item, of Item:);
if prxmatch("m/&condition/oi",icd_code) > 0;
source="Inside";
run;
@SUNY_Maggie wrote:
SAS log is attached here. Because it's too long to copy and paste in here. I noticed libname was not correctly used as defined. No idea how it happened. What else am I missing here? Million thanks.
Note that the SAS log is pure text and should therefore be posted in a text file and not a Word document. MS Office files are blocked in many places by the firewalls for security reasons. This means that, by posting a Word document, you automatically reduce the number of possible helpers for your problem.
If a txt file is too large for posting, put it in a zip archive.
I noticed one problem at line 216, namely:
216 libname read_in "P:\
and then another on page 7 of the log:
SYMBOLGEN: Macro variable CONDITION resolves to [*]V271|...|[*]7799/oi",icd_code) > 0;
Both are showing unbalanced quotation marks
Art, CEO, AnalystFinder.com
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.