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.
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;
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.
Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.
Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer.
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.