jeudi 25 janvier 2018

What's the equivalent of R sample function in Stata

I have a basic question about Stata. I have programming experience in R but I've started a new job where Stata is the main language. I'm currently diving into Stata on my own and sometimes it's hard to understand how to do simple things.

I've trying to get 5 random numbers between 3 and 50 but without success.

In R, any of these would work:

 floor(runif(5, min=3, max=50))

 sample(3:50, 5, replace=TRUE)

But I'm not sure how to do this in Stata, specifically how to return random numbers within the desired range (3:50). Any pointers would be appreciated. I found the runiform but I don't think I can get the same output.

Thank you!




Aucun commentaire:

Enregistrer un commentaire