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.

BASUG is hosting free webinars ! Next up: Art Carpenter on February 28 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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