BookmarkSubscribeRSS Feed
aloou
Obsidian | Level 7

Hello,

do you know why i get this ?

 

length COL2 varchar(*) COL3 varchar(*) COL4 varchar(*) annee_min 8 annee_max 8; 

ERROR: Cannot change variable type that is already defined for variable COL2.

2 REPLIES 2
Tom
Super User Tom
Super User

@aloou wrote:

Hello,

do you know why i get this ?

 

length COL2 varchar(*) COL3 varchar(*) COL4 varchar(*) annee_min 8 annee_max 8; 

ERROR: Cannot change variable type that is already defined for variable COL2.


The message is saying that the variable COL2 is already defined.

But your syntax does not look valid. You cannot have a variable named varchar(*) , unless you have validvarname option set to any, but even then you would need to use a name literal. 

 

If you want to define COL2 as character then you have to specify the actual LENGTH you want it to have.

length col2 $10 col3 $15 col4 $20 ...
ballardw
Super User

Suggestion: Show an entire data step or procedure, not just one line of the code. Copy the entire thing from the LOG and paste the copied text into a text box opened on the forum with the </> icon.

 

Typically I would say that you are using a data set that already has a variable named Col2 that is numeric. Then your code would be attempting to change a property of that existing variable, which SAS won't do.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 802 views
  • 0 likes
  • 3 in conversation