Dear All,
I have a numeric variable which is the median price of a property in a region. I need to add some noise to the data. Basically I would like to increase/decrease the values in the variable by no more than 1,000.
So on row 1, 176,000, might come 176,200 or on Row 2 79,000, might become 78,400.
Would anyone know how to do this?
Hello @Sean_OConnor,
With a recent SAS release such as 9.4M5 or M6 you can also use the Integer Distribution (if a discrete uniform distribution is fine):
data have;
input median_price;
cards;
176000
79000
;
data want;
call streaminit(27182818);
set have;
median_price+rand('integer',-1000,1000);
run;
Please try this:
data want;
set have;
x_noise=ceil(ranuni(1)*2000) - 1000 + x;
run;
Hello @Sean_OConnor,
With a recent SAS release such as 9.4M5 or M6 you can also use the Integer Distribution (if a discrete uniform distribution is fine):
data have;
input median_price;
cards;
176000
79000
;
data want;
call streaminit(27182818);
set have;
median_price+rand('integer',-1000,1000);
run;
Hi everyone. Interesting solution, thanks for the information.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.