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 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.
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.