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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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