Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Questions for random data generation and value label


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Questions for random data generation and value label
Date   Sat, 9 Mar 2013 20:16:15 +0100

On Fri, Mar 8, 2013 at 11:49 PM, Yu Xue wrote:
> Question 1:
> I am trying to build up synthetic/fake dataset, using random generated
> variables. Of each variable I know:
> 1) mean
> 2) standard deviation
> 3) range of values (min and max values.)
> How can I ask STATA to randomly generate a variable with all those
> specified parameters?

You have to decide from which distribution you want to draw those
variables, see: -help random_number_functions-

> Question 2:
> How to know if a variable has a value label attached? I know I can
> take a look at the result of "describe" or use "label list" to list
> all value labels. But what I want is a command that can return a value
> for each variable to show if it has value label attached or not.

you can use extended macro functions: See -help extended_fcn-.

*------------ begin example -----------------
sysuse auto
di "`: value label foreign'"
di "`: value label rep78'"
di ("`: value label foreign'" == "")
di ("`: value label rep78'" == "")
*--------------- end example ----------------

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index