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

So this seems very simple but very wired problem has confused me for so long, and it never happened like this before... Here it is:

 

I am calculating a variable called M_final = 8-(M1+M2+M3+M4+M5+M6+M7+(M8/4)

all M1 to M8 are numerical values, so I would expect M_final be a numerical value as well, also with decimal points (because M8/4), later I will need this M_final to create a character category like HighScore, LowScore

 

IDM1M2M3M4M5M6M7M8
110001014
201110001
311111113
410011100
510101010
601010012
700000101
801010111
910101013
1000000002

 

So my code in data step is (as easy as it is):

M_Score = 8-(M1+M2+M3+M4+M5+M6+M7+(M8/4));

 

but this is what SAS keeps showing me in Log:

Numeric values have been converted to character values at the places given by:

(Line):(Column).

-> it points to the line above

 

I am very confused why it happened and how to make it work as it should.

 

I've tried to use input to force the values back from character to numeric values, but it creates another problem that all decimal points are lost....

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Maybe M_score or M_final already exist as a character variable in your input dataset.

PG

View solution in original post

6 REPLIES 6
Reeza
Super User

One of the variables in your formula is not numeric.

 

Run a PROC CONTENTS and check the type.

 

 

PGStats
Opal | Level 21

Maybe M_score or M_final already exist as a character variable in your input dataset.

PG
LisaYIN9309
Obsidian | Level 7
I thought about it, but no, M_final / M_score (sorry I keep using them interchangeably) is created rather than already exist
Shmuel
Garnet | Level 18

Please post your full code and log.

Reeza
Super User

Post the PROC CONTENTS output. 

LisaYIN9309
Obsidian | Level 7

thanks @Reeza@Shmuel@Shmuel, stupid me, you guys are right. What happened is that I have different dataset from different school for calculation, some of them did have M_score/M_final in the dataset, with all missing character values. I dropped them in set step and re-create M_Score/M_final with calculation.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1929 views
  • 0 likes
  • 4 in conversation