BookmarkSubscribeRSS Feed
Ujjawal
Quartz | Level 8

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

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

data_null__
Jade | Level 19

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. 

Ujjawal
Quartz | Level 8

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.

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!

How to Concatenate Values

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.

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
  • 3 replies
  • 3030 views
  • 0 likes
  • 3 in conversation