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

I have a macro with a list of variable names that I am using as independent variables and would like to replace one the indep variables with some other one. So I initially have a macro name  oldm, and I would like to replace an oldvar in oldm with newvar and run a logit regression with the list of new variables

 

proc logistic data = mydata order=internal descending ;
model &dep =%sysfunc(tranwrd(&oldm, oldvar, newvar));
/MAXITER=1000000;
run;

 

but I kept on geeting this

NOTE: The quoted string currently being processed has become more than 262 characters long. You
might have unbalanced quotation marks.

 

thanks in advance for the help!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

This is a NOTE BTW, not a WARNING. You can ignore it, if your program works as desired.

 

I think there's a flaw in your logic. 

 

You shouldn't look at replacing the value using TRANWRD but on obtaining each word in turn. You can use %SCAN() for this instead.

RIght now, you'd have to know what word to replace in TRANWRD, but if you know it why replace it and not use it directly.

 

The example below shows you how to loop through the values in a list, which is what I think you're after. But I'm really guessing because you haven't provided enough information and your non-working code has some logic fails.

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#p1n2i0ewaj1zian1r...

 

If all you want is TRANWRD to operate using SYSFUNC() then see the example below. Note that you have to have macro variables for the second and third parameter as well.

 

%let string= This is my first test string;
%let oldvar = first;
%let newvar = second;

%put %sysfunc(tranwrd(&string, &oldvar, &newvar));

 

 

View solution in original post

4 REPLIES 4
Reeza
Super User

That sounds a lot like the last/second last example on this page:

http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/

Newph
Calcite | Level 5

is there a way to code it in sysfunc directly? any help would be greatly appreciated

Reeza
Super User

This is a NOTE BTW, not a WARNING. You can ignore it, if your program works as desired.

 

I think there's a flaw in your logic. 

 

You shouldn't look at replacing the value using TRANWRD but on obtaining each word in turn. You can use %SCAN() for this instead.

RIght now, you'd have to know what word to replace in TRANWRD, but if you know it why replace it and not use it directly.

 

The example below shows you how to loop through the values in a list, which is what I think you're after. But I'm really guessing because you haven't provided enough information and your non-working code has some logic fails.

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#p1n2i0ewaj1zian1r...

 

If all you want is TRANWRD to operate using SYSFUNC() then see the example below. Note that you have to have macro variables for the second and third parameter as well.

 

%let string= This is my first test string;
%let oldvar = first;
%let newvar = second;

%put %sysfunc(tranwrd(&string, &oldvar, &newvar));

 

 

Newph
Calcite | Level 5

Thanks so much for the help!

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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