Hi,
When I ran the code I got error message in log, what does it mean by variable contains more than 32 bytes. Any solutions are highly appreciated. Thank you.
data project2;
set project1;
state_marijuana_legal_status1=state_marijuana_legal_status;
if followUp=2 and date_recreational_marijuana_legalized > "01JUL2020"d then state_marijuana_legal_status1=1;
if followUp=5 and date_recreational_marijuana_legalized > "01DEC2020"d then state_marijuana_legal_status1=1;
if followUp=7 and date_recreational_marijuana_legalized > "01MAY2021"d then state_marijuana_legal_status1=1;
if followUp=8 and date_recreational_marijuana_legalized > "01SEP2021"d then state_marijuana_legal_status1=1;
if followUp=10 and date_recreational_marijuana_legalized > "01MAR2022"d then state_marijuana_legal_status1=1;
run;
The variable name in your code, date_recreational_marijuana_legalized, is longer than 32 characters. This is not allowed in SAS datasets, therefore this variable cannot exist in work.project1. Suggest running PROC CONTENTS on work.project1 to check the variable name.
This (poorly worded) error message is about the variable name, not data in the variable. You can generate it with:
1 data _null_ ; 2 date_recreational_marijuana_legalized=1 ; ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes. 3 run ; NOTE: The SAS System stopped processing this step because of errors.
I think maybe the error message is intended to be "ERROR: The variable name date_recreational_marijuana_legalized contains more than 32 bytes." So name, not named.
The names of variables in SAS is limited to 32 characters.
You are attempting to use/create variables with names longer than that. Since SAS won't let you create such then you need to check your data set to check the actual spelling.
Shorten the name of the variable to the 32 or fewer characters actually in the set Project1. If you don't actually know the names then run:
Proc contents data=project1; run;
to show the names and properties of the variables.
Personally the number of variables that I create with names longer than 16 characters are few and far between as I am too lazy to type that stuff hundreds of times.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.