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

I'm using SAS Studio on a MacBook Pro with VirtualBox and Safari. I wrote a macro that used to work, but now does not with the following log messages:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
2 TITLE;
3 FOOTNOTE;
4 OPTIONS LOCALE=en_US DFLANG=LOCALE;
WARNING: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation
marks.
140 &GRAPHTERM; ;*';*";*/;RUN;QUIT;
_________________
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.
 
___MORE LOG LINES, THEN MY CODE___
 
options mprint symbolgen MAUTOSOURCE SASAUTOS="/folders/myfolders/SASMacs";
WARNING: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation
marks.
57 data birthwt; set npar.birthwt;
58 if program="Drug" then Trt=1;
59 else if program="Placebo" then Trt=2;
60 %macro Moses(data=birthwt,class=Trt,var=birthwt,k=4,exact=yes)
 
Any suggestions?
 
Thanks.
 
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

For that &GRAPHTERM, that must be something being setup in the auto run of SAS, maybe in an autoexec.sas file, or something similar, you might want to check that to see if its been setup correctly, check all the options are up and running.

http://stackoverflow.com/questions/30287508/how-can-i-disable-automatic-options-statements-in-sas-un...

 

Sorry, I am not reading that code, it breaks every rule of easy to read code I can think of (indentation, finishing steps, ending macro variables etc.).  At a guess, as your using lots of call symputs, its likely one of those is being generated that contains either quotes, or something else which is causing problems.  comment out the whole macro and run it adding a step at a time, there is a lot in that code that looks suspicious to me.  the first datastep, you have an if then around assigning charclass, but then afterwards just assign it TRT without any logic?  And this line:

 

Doesn't seem to do anything?

%if %upcase(%substr(&exact,1,1))=Y %then %str(exact wilcoxon);

 

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is this line doing?

140 &GRAPHTERM; ;*';*";*/;RUN;QUIT;

What does &graphtemr decode to?  Why not finishi it with a full stop.  Why the sequence of semicolons, asterix, quotes, and run quit?  It looks like there was a problem before with unbalanced quotes, and this has been patched up with that sequence.

 

If you want my suggestion, I would take this moving to a new system as a good opportunity to do some software lifecycle management on this, look at all the code, see what is needed, why its needed, update it to the latest SAS functionality etc.  And document everything!

 

In a normal production environment this should be done at least once a year, reassess against Functional Design Specifcation and requirements, check code still does what it should, re-test, look at new requests etc.

rsteiner
Calcite | Level 5
Hi RW9,

Thanks for responding so quickly. The line

140 &GRAPHTERM; ;*';*";*/;RUN;QUIT;

isn¹t part of the code I wrote. It just came out in the log. I was
assuming this was something that SAS Studio generated. I just wrote this
over the weekend and it ran yesterday. Here is my code:

options mprint symbolgen MAUTOSOURCE SASAUTOS="/folders/myfolders/SASMacs";
data birthwt; set npar.birthwt;
if program="Drug" then Trt=1;
else if program="Placebo" then Trt=2;
%macro Moses(data=birthwt,class=Trt,var=birthwt,k=4,exact=yes)

And here is the macro:

%macro Moses(data=_last_, class=, var=, k= , exact=no);
data &data; set &data nobs=n;
Shuffle=ranuni(2394857);
/* Check for numeric class variable */
type=vtype(&class);
CALL SYMPUT('type',TRIM(LEFT(PUT(type,$1.))));
if type="N" then do;
charclass=STRIP(PUT(&class, z10.));
end;
else do;
length charclass $10.;
charclass=&class;
end;
/*==================================*/
proc sort out=&data; by &class Shuffle;
proc means noprint;
class &class;
var &var;
output out=SamSize n=n;
data n1; set SamSize; if _N_=2;
CALL SYMPUT('n1',TRIM(LEFT(PUT(n,10.))));
CALL SYMPUT('grp1',TRIM(LEFT(PUT(&class,$10.))));
data n2; set SamSize; if _N_=3;
CALL SYMPUT('n2',TRIM(LEFT(PUT(n,10.))));
CALL SYMPUT('grp2',TRIM(LEFT(PUT(&class,$10.))));
data Group1;
do j=1 to floor(&n1/&k);
do i=1 to &k;
subgroup=j;
set &data; if &class=%str("&grp1");
output;
end;
end;
data Group2;
do j=1 to floor(&n2/&k);
do i=1 to &k;
subgroup=j;
set &data; if &class=%str("&grp2");
output;
end;
end;
data Group1; Set Group1;
if _N_>&n1-mod(&n1,&k) then delete;
data Group2; Set Group2;
if _N_>&n2-mod(&n2,&k) then delete;
proc append base=Group1 data=Group2;
proc summary noprint;
class &class subgroup;
var Na;
output out=Variances var=Variance;
data Variances; set Variances;
if _TYPE_ < 3 then delete;
proc npar1way wilcoxon;
class &class;
var Variance;
%if %upcase(%substr(&exact,1,1))=Y %then %str(exact wilcoxon;);
title "Moses Rank-like Procedure";
run;
%mend Moses;


Thanks again!

##- Please type your reply above this line. Simple formatting, no
attachments. -##
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

For that &GRAPHTERM, that must be something being setup in the auto run of SAS, maybe in an autoexec.sas file, or something similar, you might want to check that to see if its been setup correctly, check all the options are up and running.

http://stackoverflow.com/questions/30287508/how-can-i-disable-automatic-options-statements-in-sas-un...

 

Sorry, I am not reading that code, it breaks every rule of easy to read code I can think of (indentation, finishing steps, ending macro variables etc.).  At a guess, as your using lots of call symputs, its likely one of those is being generated that contains either quotes, or something else which is causing problems.  comment out the whole macro and run it adding a step at a time, there is a lot in that code that looks suspicious to me.  the first datastep, you have an if then around assigning charclass, but then afterwards just assign it TRT without any logic?  And this line:

 

Doesn't seem to do anything?

%if %upcase(%substr(&exact,1,1))=Y %then %str(exact wilcoxon);

 

 

rsteiner
Calcite | Level 5
Thanks, RW9. I appreciate your time and suggestions.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2571 views
  • 0 likes
  • 2 in conversation