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

I have a code with a data set with a variable titled average with the average housing prices by month since 1975. These observations are in char format and need to be converted to numerics. The code is below:

 

data mortdata.housingproces; set mortdata.house_price;

AVG = input(average, Best5.);

run;

 

This isn't working, and I'd like to know why. The output that I keep getting is just "." for all the rows.

 

Thank you for your help in advance!  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Does you text value have commas? Show some example values, what you are currently getting for results and what you expect.

 

View solution in original post

8 REPLIES 8
Reeza
Super User

BEST5 seems low for house prices, have you tried BEST12?

 

Post your log as well please.

uttara_96
Calcite | Level 5
I tried BEST12, but the output was the same.
Reeza
Super User

Post your code and log.

ballardw
Super User

Does you text value have commas? Show some example values, what you are currently getting for results and what you expect.

 

uttara_96
Calcite | Level 5

My text values had commas in them, and I removed them right now. The results are now populating. Thank you so much for y'all's help!

Reeza
Super User

The informat represents the format your data was in.

 

So it should have been something like:

 

input(average, comma12.);

 

ShiroAmada
Lapis Lazuli | Level 10

 

 

data mortdata.housingproces; set mortdata.house_price;

AVG = average+0;

run;

Reeza
Super User

@ShiroAmada wrote:

 

 

data mortdata.housingproces; set mortdata.house_price;

AVG = average+0;

run;


Implicit conversion isn't a great idea in the long run. It will leave notes in the log and make it hard to distinguish actual errors, if they crop up later on. 

 

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
  • 8 replies
  • 2695 views
  • 4 likes
  • 4 in conversation