I am storing numeric variable names in a macro variable. Then i loop each of the numeric variables one by one and doing some analysis. The code is shown below. It is unfortunate i cannot share the whole code. I have pasted the code where in the main error comes. Is there a way i can store numeric variables exceeding 65K?
ERROR: The length of the value of the macro variable VAR_IV (65540) exceeds the maximum length (65534). The value has been
truncated to 65534 characters
112 proc sql noprint;
113 select name into : var_iv separated by " "
114 from dictionary.columns
115 where LIBNAME = "&library"
116 and MEMNAME = "INPUT1"
117 and type = 'num' and UPCASE(name) ^= "&depvar";
118 quit;
119
124
125 * Count number of variables;
126 %let varn=%sysfunc(countw(&var_iv%str( )));
127
128 *Run for all the numeric variables;
129 %DO i=1 %TO &varn;
130
131 *Selecting Variable one by one;
132 %let varName =%qscan(%sysfunc(compbl(&var_iv)),&i,%str( ));
133 %put &varName &i.;
134
135 *Create ranks for the variables;
136 PROC rank data=&input. (keep= &depvar &varName.) group= &Bins. out= varsel_3 ties=low ;
137 var &varName.;
138 ranks Rank_group;
139 RUN;
ERROR: The length of the value of the macro variable VAR_IV (65540) exceeds the maximum length (65534). The value has been
truncated to 65534 characters
Well, my advice in these situations, don't use macro language. There's really no need.
proc sql noprint;
create table LOOP as
select name
from dictionary.columns
where LIBNAME = "..."
and MEMNAME = "..."
and type = 'num' and UPCASE(name) ^= "....";
quit;
Slightly changing your first step will give you a nice dataset with one row per variable. We can then use this datastep, which is in essence already a loop over observations to generate the necessary code:
data _null_;
set loop;
call execute('proc rank data=... (keep=...) group=... out=... ties=low;
var ...;
ranks ...;
run;');
run;
The above will generate the proc rank code with each of the variables from the loop dataset.
Stop wait don't do all that looping and calling PROC RANK so many time when you only need to call it once.
Is it essential that you create a data set with the original IV and the RANK_GROUP (the ranked IV)? The answer to that question is important.
Thanks a ton RW9 for your suggestion. I have a long list of code that runs in loop (almost 500 lines of code). It includes PROC SQL. Can it be run under CALL EXECUTE? Is there any limit number of lines of code can be written with CALL EXECUTE.
@DATA_NULL : Yes it is required to create a data set with original IV and RANK_GROUP as this decile information would be used to calculate WOE (Weight of Evidence) for each variables.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.