I've created one variable in data step as follows. Meaning I creating the variable 'knkath' and it should equal to the other character variable 'knkatd'. In the same data step I'm using link statement and file statement to create the output file. When I execute the code, I got warning as shown below. Not sure how and where the variable 'knkath' has been defined as numeric. Is there any way to fix this warning?
knkath = knkatd;
Log:
219 @35 knkath $2.
220
221 @37 knabew 3.
WARNING: Variable knkath has already been defined as numeric.
By now you should know that posting such small snippets is useless to detect the problem. You make yourself appear quite silly.
It's a very big program to share with and that's why I gave only the snippet.
The only guess I can give you:
if
knkatd
is numeric, then
knkath
will also be numeric, and you can't use a character format for it.
@Babloohave you tried to put debuggers in your programs.
If you are using a datastep you can debug some issue like this:
data junkout / debug;
set junkin;
….. bunch of stuff you want to do.....
run;
when you execute the process you can line step through the datastep.
try it you may find that you have the answer right in front of you.
@Babloo wrote:
I've created one variable in data step as follows. Meaning I creating the variable 'knkath' and it should equal to the other character variable 'knkatd'. In the same data step I'm using link statement and file statement to create the output file. When I execute the code, I got warning as shown below. Not sure how and where the variable 'knkath' has been defined as numeric. Is there any way to fix this warning?
knkath = knkatd;
Log:
219 @35 knkath $2. 220 221 @37 knabew 3. WARNING: Variable knkath has already been defined as numeric.
If you can't include the whole program that at least show the very first line that include the problem variable. That is likely what has set the variable type.
OR if you have a SET, MERGE, UPDATE or MODIFY statement the characteristic of variable type could come from being in one of the data sets contributing.
Hi @Babloo I recommended you to get hold of author Ron cody's book Learning SAS by example and get started seriously in of your posts. I was exactly or worse off 5-6 years ago when I was an absolute beginner in SAS. However some reading effort paid off.
I feel the pain that you are going through however I didn't resort to communities for extreme basics rather it was the book. I would like you to do the same and get up-to speed. If I can learn, anybody can!
@Babloo wrote:
I have already given the first line of the problem variable in the OP
But you have not indicated which is the first line. The assignment was copied from the editor so there is no line indicator as from the log.
If this is the actual first use of he variable knkath then knkatd is character. If you have variables coming from a SET, MERGE, UPDATE or MODIFY statement and the variable KNKATH was in one of those data sets then that set it's type as numeric.
knkath = knkatd;
Run Proc contents on all of the datasets contributing and verify that none of them have KNKATH as a variable. Show the results.
If knkath is numeric and kntatd is character then there would be a corresponding LOG entry similar to:
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 74:6
is there?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.