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. 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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