BookmarkSubscribeRSS Feed
Dawa93
Fluorite | Level 6

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;
 
I got this error message in my log:
 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 data project2;
70 set project1;
71 state_marijuana_legal_status1=state_marijuana_legal_status;
72 if followUp=2 and date_recreational_marijuana_legalized > "01JUL2020"d then state_marijuana_legal_status1=1;
ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes.
73 if followUp=5 and date_recreational_marijuana_legalized > "01DEC2020"d then state_marijuana_legal_status1=1;
ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes.
74 if followUp=7 and date_recreational_marijuana_legalized > "01MAY2021"d then state_marijuana_legal_status1=1;
ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes.
75 if followUp=8 and date_recreational_marijuana_legalized > "01SEP2021"d then state_marijuana_legal_status1=1;
ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes.
76 if followUp=10 and date_recreational_marijuana_legalized > "01MAR2022"d then state_marijuana_legal_status1=1;
ERROR: The variable named date_recreational_marijuana_legalized contains more than 32 bytes.
77 run;
4 REPLIES 4
Quentin
Super User

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 Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
Dawa93
Fluorite | Level 6
Thank you!! It worked after shortening the name of the variable.
ballardw
Super User

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.

Dawa93
Fluorite | Level 6
Thank you!! It worked after shortening the name of variable.

SAS Innovate 2025: Register Now

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 862 views
  • 0 likes
  • 3 in conversation