06-14-2013 01:18 PM
Can anybody help me with the following problem:
I have a program that runs without error when I open it and then run it. As soon as the program is called by another program (which I need to do), I get the warning "T he quoted string currently being processed has become more than 262 characters long. You may have unbalanced quotation marks." After that a macro variable which is created by a PROC SQL is not created correctly. The code where the problem occurs is something like that:
into :mylist separated by ' '
where libname='WORK' and memname='MYDATA' and name not in ("vara","varb","varc");
Has anyone experienced something similar? How can I get around that?
Thanks in advance for your help.
06-14-2013 01:54 PM
Yes, I have run into that, specifically when calling a program using gsubmit. What does the code look like that is being used to call the program you posted? It would help if you posted that code as well.
06-14-2013 01:55 PM
I can think of three things to check.
1) Are there quotes being put into macro variable by SQL such that when you used it later in the process you end up with unbalanced quotes? Should not happen with that particular query.of variable NAMEs, but if you are pulling other variables they might. Then you need to check how the variable is used. If the value of the macro contains double quote character and you wrap it in double quotes then you could end up with unbalanced quotes. You might need to use macro quoting or regular QUOTE() function to make sure that internal double quotes are handled properly.
2) Is the value longer than can fit in one macro variable? Especially if it has quotes. So you might have validly doubled the quotes in the individual values being pulled, but when it was truncated they became unbalanced.
3) How are you "calling" it from another program? Perhaps the quoting in the other program is wrong? Perhaps the lines are too long and the method you are using to call it from another program are truncating code lines?
06-14-2013 04:45 PM
As per Tom's note 3), if you wrap code into a macro, the line length can only be a specific length (256 long I believe). If you have very long coded lines (longer than 1 - 2 screens of code) the macro is liking cutting off the code here. If you had a quoted string before it was cut off, then that will lead directly to your error.
I know this because I was not aware of the macro line length issue and one of my programs had this exact problem, and it took me FOREVER to figure out what was going wrong.
Ex: This will not work if wrapped into a macro
if oldvar1='the variable to check for' and oldvar2='' and issue_comment='Remediation within process' and ........ then finalvar="The borrower needs to take immediate action to make sure a foreclosure YADA YADA YADA';
Basically, the sytem would cut off within your finalvar definition, so the code would only read up to the fore in foreclosure, and you would then have un-even quotes.
Hope that helps!
06-16-2013 12:09 PM
Thanks for your help.
To call the programm I use %include.
To point 2.) of Toms answer: Yes it is quite a large value which is stored in the macro variable. But it works if I run the program for itself, only as soon as I use %include it does not work anymore.
06-16-2013 12:50 PM
I would check the program. Try reading it as data in a data step.
It is possible that lines are truncated when you pull the file into the SAS program editor and there are extra characters are in the file that get included withe %INCLUDE statement.
Personally I never write program code with lines longer than 80 characters. There is a reason why newspapers are divided into columns. Longer lines are harder for humans to read.
Note that warnings about long quoted strings do not necessarily mean an actual error. If you want to put 300 characters into a macro variable and then use it in a expression that requires quoting it will work. As with any SAS error message use the location of the error as the starting point in your search for the underlying cause of the error. It could be many statements earlier, especially for unbalanced quotes.
06-17-2013 05:37 AM
Thanks for your help Tom.
I finally found the problem. It occured already in the data step before the PROC SQL. There I had a long string assigned to a variable. That caused an unbalanced quotation mark which made the PROC SQL not work properly. I now could solve the problem by adding the lrec options to the %include statement (%include "myfile" / lrec=500).
06-17-2013 12:19 PM
Glad to help. You really should convert the program file to use shorter lines. You will not be able to maintain it with lines that long. How could you even view the code?