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: Stata equivalent of SAS code


From   tunmise jones <[email protected]>
To   Dan Blanchette <[email protected]>
Subject   Re: st: Stata equivalent of SAS code
Date   Sat, 21 Jan 2012 00:28:59 +0000

Tried out the code and it does work. Thanks a lot Dan.

On Fri, Jan 20, 2012 at 3:38 PM, Dan Blanchette <[email protected]> wrote:
> This should be the Stata code you want to use:
>
>  . gen owner= "FO"  if !inlist(upper(trim(loc_other)), "", "0", "00", "NG",
> "NI")
>  . replace owner= "DO"  if missing(owner)
>
> You have to use the trim() function in case loc_other is just 1 or more
> blank
> spaces. The inlist() function is limited to no more than 9 values and 1
> variable
> when testing a string variable.
>
> Since you are more used to SAS, check out my "SAS Users Guide to Stata"
> webpage:
>
>  http://www.cpc.unc.edu/research/tools/data_analysis/sas_to_stata
>
> One of the pages has SAS code matched to the equivalent Stata code:
>
>  http://www.cpc.unc.edu/research/tools/data_analysis/sas_to_stata/sas_to_stata.html
>
> HTH,
> Dan Blanchette
>
> Research Programming Services
> Carolina Population Center
> University of North Carolina
> [email protected]
>
>
>
>
>>  On 19 Jan 2012, at 13:07, tunmise jones <[email protected]> wrote:
>>
>>
>>    Dear Statalisters,
>>
>>     I am new to Stata and currently working with a large panel dataset of
>>    firms over a period of 9 years. I want to analyse the data based on
>>    the nationality of ownership. There are two ownership variables;
>>    location (1 = domestic, 2= foreign) and location other (1= foreign, 2
>>    =domestic). Different codes were used at different times over the
>>    survey period to represent domestic ownership which creates some
>>    inconsistencies.  Prior to a certain point in time in the data, the
>>    "location" variable does not really work, "location_ other" is the
>>    main ownership variable.  However, many companies enter 2 in the
>>    location variable indicating foreign ownership but leave the
>>    location_other variable blank making it hard to determine nationality
>>    since the location variable is not very reliable in all the years.
>>
>>    I need a Stata equivalent of the the SAS code given below:
>>
>>    if location = '2' or upcase(loc_other)
>>                            not in ('','0','00','NG','NI') then owner =
>>    'FO';
>>                    else owner = 'DO';
>>
>>
>>    In the SAS code above "upcase(loc_oth)" makes character values upper
>>    case. The code is designed in such a way that every company is
>>    assigned a value of "owner", minimising the number of cases lost, i.e.
>>    if a firm has entered 2 under "location", or has a value entered under
>>     "location_other" and is not empty or has the various codes used to
>>    denote domestic ownership, then it is foreign, otherwise it is
>>    domestic. Where a company has not entered anything, then zero is
>>    introduced automatically  and the above code forces such a company to
>>    become domestic.
>>
>>    I have no idea how to replicate this in Stata, can anyone please help?
>>
>>
>

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


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