Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Stata equivalent of SAS code


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Stata equivalent of SAS code
Date   Thu, 19 Jan 2012 14:04:09 +0000

Start by looking at

help for functions, specifically -upper()-, -inlist()-

help for operators, specifically == and !

help for -generate-

Nick

On 19 Jan 2012, at 13:07, tunmise jones <tunmisejones@gmail.com> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index