Programming the statistical procedures from SAS

%sysfunc

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

%sysfunc

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!


Accepted Solutions
Solution
‎02-06-2017 03:31 PM
Grand Advisor
Posts: 16,839

Re: %sysfunc

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


All Replies
Grand Advisor
Posts: 16,839

Re: %sysfunc

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

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

Occasional Contributor
Posts: 13

Re: %sysfunc

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

Solution
‎02-06-2017 03:31 PM
Grand Advisor
Posts: 16,839

Re: %sysfunc

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));

 

 

Occasional Contributor
Posts: 13

Re: %sysfunc

Thanks so much for the help!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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