Hi,
I am having trouble labeling all of a certain type of variable with the same label.
The code that I have is the following:
%macro Label(Exp);
data sub.master_dataset053019;
set sub.master_dataset053019;
%do i=1 %to %sysfunc(countw(&exp));
%let thisexp=%scan(&exp,&i,%str( ));
label I_PostResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr1st6mo_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr1st6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PreResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
I_PostResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
%end ;
run;
%mend;
%label(house consume durable Trans health Insure Loan Tax Educa Gift Enter REcre FinPlan Legala AlcSpend ST2DENOM2 ST2DENOM3 ExpendTl FinPlSav IncomeTL ST2Oblig);
I an receiving 1787 errors indicating that my text is too long, but it doesnt seem to pass the 256 characters in the label?
Error:
1 ;*';*";*/;quit;run;
ERROR: The text expression length (65580) exceeds maximum length (65534). The text expression has been truncated to 65534
characters.
I am at a loss. Could I be using the macro inappropriately? I have used almost the same macro more than once and it worked flawlessly.
Any help would be appreciated.
If this is supposed to be a block of label instructions:
label I_PostResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1st6mo_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1st6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
You have too many semi colons.
Try
label I_PostResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1st6mo_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1st6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" ;
Other than the first line with the actual LABEL statement SAS thought you were attempting to assign the string as the value of the variable, NOT a label.
BTW you don't need the %str() in this:
%let thisexp=%scan(&exp,&i,%str( ));
as a blank is a default parameter for %scan. Use
%let thisexp=%scan(&exp, &I );
The error of exceeding character length probably means you have gotten into an unstable state, probably due to a mismatched quote or () somewhere. Save the code and restart SAS.
If this is supposed to be a block of label instructions:
label I_PostResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1st6mo_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1st6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PreResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs"; I_PostResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs";
You have too many semi colons.
Try
label I_PostResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1st6mo_&thisExp = "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1st6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2nd6mo_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1stQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2ndQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr3rdQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr4thQ_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr1stT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr2ndT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PreResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" I_PostResYr3rdT_&thisExp= "+1 to all I_ Variables for 0's in prop/Logs" ;
Other than the first line with the actual LABEL statement SAS thought you were attempting to assign the string as the value of the variable, NOT a label.
BTW you don't need the %str() in this:
%let thisexp=%scan(&exp,&i,%str( ));
as a blank is a default parameter for %scan. Use
%let thisexp=%scan(&exp, &I );
The error of exceeding character length probably means you have gotten into an unstable state, probably due to a mismatched quote or () somewhere. Save the code and restart SAS.
@ballardw As always, you are a wizard. I had tried an iteration without all the semi-colons and assumed I was incorrect.
Saving and restarting did the trick. Thank you!
Also, good to note about blank being the default parameter for scan. I appreciate you taking your time to help me!
Hi @joebacon,
If the macro adds or modifies variable labels, but doesn't change variable values (or the structure of the dataset), there is no need to read and write the whole (possibly huge) dataset using a DATA step. PROC DATASETS could do this much more efficiently:
proc datasets lib=sub nolist;
modify master_dataset053019;
label ...
...
;
quit;
For the LABEL statement use the same syntax as you did in the DATA step (after the correction). Also the macro logic remains unchanged.
Man, I have been on many forums and this one is the only one that the individuals truly go out of their way to help you.
Thank you so much! Computationally, that is way faster. A great suggestion that I would have never even attempted.
@joebacon wrote:
Man, I have been on many forums and this one is the only one that the individuals truly go out of their way to help you.
Thank you so much! Computationally, that is way faster. A great suggestion that I would have never even attempted.
A data step always loads all of the records into the data vector and then writes them to the output data set and that can take time that is noticeable when the data set is even only moderate in size.
The Proc Datasets is writing to the header information of the file so even when a data set is many times larger the time involved is almost the same,
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.