BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cruise
Ammonite | Level 13

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

 

 

 

View solution in original post

12 REPLIES 12
art297
Opal | Level 21

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

AndrewHowell
Moderator

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?

 

ballardw
Super User

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.

Cruise
Ammonite | Level 13

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. 

 

 

art297
Opal | Level 21

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

 

Cruise
Ammonite | Level 13

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. 

Reeza
Super User

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;

 

 

 

Kurt_Bremser
Super User

@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.

art297
Opal | Level 21

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

Peter_C
Rhodochrosite | Level 12
Try a %THEN %DO ;
before the line
PROC DATASETS NOPRINT;
Peter_C
Rhodochrosite | Level 12
Apols
Couldn't see the off-screen text
Cruise
Ammonite | Level 13
I took it down due to confidentiality reason. dealing with individual patient data and couldn't mask it off well in 14 page log. It worked out now though, the problem was when I define data to 2015. i didn't have physical data existed for that year. Thanks Peter.

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 connect to databases in SAS Viya

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.

Discussion stats
  • 12 replies
  • 7358 views
  • 5 likes
  • 7 in conversation