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
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
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 <[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/