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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.