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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.