BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hjjijkkl
Pyrite | Level 9

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.


 

View solution in original post

7 REPLIES 7
AMSAS
SAS Super FREQ

Your variable name is longer than 32 characters (33)

Here's a link to the documentation on Rules for Variable Names 

AMSAS
SAS Super FREQ

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
Tom
Super User Tom
Super User

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

hjjijkkl
Pyrite | Level 9

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.

hjjijkkl
Pyrite | Level 9

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;

Reeza
Super User
Run a proc contents on your data set and see what length the variable has...or use SQL Pass through to rename the column while you import the data.

From this, do you see the variable with the name and length specified?

proc contents data=combine;
run;
Kurt_Bremser
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 7 replies
  • 2995 views
  • 0 likes
  • 5 in conversation