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!
Does you text value have commas? Show some example values, what you are currently getting for results and what you expect.
BEST5 seems low for house prices, have you tried BEST12?
Post your log as well please.
Post your code and log.
Does you text value have commas? Show some example values, what you are currently getting for results and what you expect.
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!
The informat represents the format your data was in.
So it should have been something like:
input(average, comma12.);
data mortdata.housingproces; set mortdata.house_price;
AVG = average+0;
run;
@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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.