BookmarkSubscribeRSS Feed
marleeakerson
Calcite | Level 5

hello, 

 

I am trying to do a simply conversion from decimal to percent (ex: .91 to 91%) so I am trying to multiply my variable by 100, but I keep getting these errors: 

 

NOTE: Invalid numeric data, 'Percent_X' , at line 1343 column 28.
NOTE: Invalid numeric data, 'Percent_Y' , at line 1344 column 26.
NOTE: Invalid numeric data, 'Percent_Z' , at line 1345 column 16.

NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line):(Column).
75 at 1343:54 75 at 1344:51 75 at 1345:30

 

What am I doing wrong? 

 

here is my code: 

 

data want;
set have;
Percent_X = "Percent_X" * 100 ;
Percent_Y = "Percent_Y" * 100;
Percent_Z = "Percent_Z" * 100;
run;

 

Thank you! 

2 REPLIES 2
novinosrin
Tourmaline | Level 20

Try removing the quotes around variable names if they are actually variable names

 

Alternatively, you could just FORMAT the values using percent. format like

 

format Percent_X  percent.;
PaigeMiller
Diamond | Level 26

In your code, where you have 

 

"Percent X"*100

 

the text inside the quotes is a character string which cannot be used in arithmetic.

 

You may want

 

percent_x=percent_x*100;

note that percent_x is a variable name, it is not in quotes, and it contains an underscore instead of a space as you originally wrote it, but this method does not append a % character after the number ... so ...

 

probably better is to leave the value unchanged, do not perform the above step, and instead apply the PERCENTw.d format to the variable percent_x, for example

 

format percent_x percent8.2;

 

which makes the value of the variable appear as if it had been multiplied by 100 and appends a % character after the number.

 

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 458 views
  • 0 likes
  • 3 in conversation