BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sean_OConnor
Fluorite | Level 6

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?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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;

 

View solution in original post

4 REPLIES 4
yabwon
Onyx | Level 15
Hi,

try: (RAND("uniform")*2000 - 1000)

but before that use: call streaminit(123);

All the best
Bart
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ed_sas_member
Meteorite | Level 14

Hi @Sean_OConnor 

Please try this:

data want;
	set have;
    x_noise=ceil(ranuni(1)*2000) - 1000 + x;
run;
FreelanceReinh
Jade | Level 19

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;

 

johnmorgan
Calcite | Level 5

Hi everyone. Interesting solution, thanks for the information.

check out my project here

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 650 views
  • 2 likes
  • 5 in conversation