I am exporting data from a big database to SAS and I was using if/then statement to specify the variable but, I am getting and error saying "ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes." And I dont know how to correct it. I don't see any error in exporting the data to SAS. Need help! Thanks!
The string "survey_response_tracking_complete" consists of 33 characters, so it cannot be the name of a variable in a SAS dataset. Double-click on the dataset in library WORK, and see how the name ended up after importing the table into SAS.
@hjjijkkl wrote:
Here is the program and log
data combine1;
set combine;
length survey_response_tracking_complete $10;if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';run;
if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1915 if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1916 if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
Your variable name is longer than 32 characters (33)
Here's a link to the documentation on Rules for Variable Names
Here's an example of the SAS Log when you try to create a variable name longer than 32 characters
850 data temp ;
851 survey_response_tracking_complete="" ;
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
852 run ;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TEMP may be incomplete. When this step was stopped there were 0
observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.05 seconds
cpu time 0.00 seconds
@hjjijkkl wrote:
I am exporting data from a big database to SAS and I was using if/then statement to specify the variable but, I am getting and error saying "ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes." And I dont know how to correct it. I don't see any error in exporting the data to SAS. Need help! Thanks!
Please show what code you are running. Include the log with the notes from SAS. Make sure to paste the text into the pop-up window you get when you click on the Insert Code button (looks like </>).
Variables can be much longer than 32 bytes, but the NAME you use to reference the variable in SAS code cannot be longer than 32 bytes.
If you are exporting the data from some other database then use the syntax/language of that database to export the data. You can then use SAS code to read in the data you exported and at that point you can just use valid names for your variables.
Here is the program and log
data combine1;
set combine;
length survey_response_tracking_complete $10;
if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';
run;
if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1915 if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1916 if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
sorry this is the correct program
data combine1;
set combine;
length srvy_response_tracking_comp $10;
if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';
run;
The string "survey_response_tracking_complete" consists of 33 characters, so it cannot be the name of a variable in a SAS dataset. Double-click on the dataset in library WORK, and see how the name ended up after importing the table into SAS.
@hjjijkkl wrote:
Here is the program and log
data combine1;
set combine;
length survey_response_tracking_complete $10;if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';run;
if survey_response_tracking_complete= 0 then srvy_response_tracking_comp='Incomplete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1915 if survey_response_tracking_complete= 1 then srvy_response_tracking_comp='Unverified';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
1916 if survey_response_tracking_complete= 2 then srvy_response_tracking_comp='Complete';
ERROR: The variable named survey_response_tracking_complete contains more than 32 bytes.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.