Posted on 12 March 2015 by Mitch Abdon
In a comment to the previous post
destring complication: negative numbers
, Nick Cox pointed out “the most important advise” in using
unless you are absolutely sure that you are right or are willing to do things again if you made the wrong decision. The
option is there for a purpose.”
In addition, his comment point to simpler solution than using regular expressions.
Filed under: Basic functions, Data Management | Tagged: charlist, destring, real(), regular expressions, tabulate | 1 Comment »
Posted on 10 March 2015 by Mitch Abdon
Less than 2 hours flight…
In a Stata training, one of the students wondered why after importing an Excel file of financial indicators into Stata some were read as strings. A quick browse at the data indicates the presence of hyphens (“-“) and that these were used in different ways: one to indicate a negative number and another to indicate a missing observation.
How do we convert these variables to numeric as
returns an error?
Filed under: Basic functions, Data Management | Tagged: charlist, destring, regexm, regular expressions | 2 Comments »
Posted on 10 February 2015 by Mitch Abdon
How do we import data from all sheets in a number of Excel files? Each Excel file has a different number of sheets with names of no discernible pattern, but (thankfully) each sheet has the same structure: the first observation is in the same row and the columns correspond to each other. An example is the set of 17 Excel files of census data of barangays
(villages) that was provided to me. Each Excel file corresponds to one region and within each file are sheets corresponding to the province in the region. How do we consolidate all sheets in all files into one data file?
Filed under: Basic functions, Basic Programming, Data Management | Tagged: excel, foreach, fs, import, import excel | Leave a comment »
Posted on 18 January 2015 by Mitch Abdon
clean results window
in Stata thirteen, typing
Filed under: Basic functions | Tagged: clear screen, cls | Leave a comment »
Posted on 8 January 2015 by Mitch Abdon
In the Philippines, there has been an emerging demand in the public sector for data-driven analysis of various govenrment programs (yes, emerging.. don’t ask why.. but the leadership has a lot to do with this.. bless them). I am lucky enough to be invited to introduce Stata to some government agencies (and some private institutions) and how it can be used with their data. Often the the question where to get a copy of Stata pops up. So, for reference: here is the sole distributor of Stata in the country:
Filed under: Books and websites | Tagged: distributor, Philppines, Stata | 2 Comments »
Posted on 7 January 2015 by Mitch Abdon
Sometimes we want to break a continuous variable into a smaller set of categories—into evenly spaced or equally sized groups, or groups based on limits we specify, or groups based on another variable or a set of variables.
Let us take for example the variable
of cars in auto.dta
sysuse auto.dta, clear // open a Stata built-in data
Filed under: Basic functions | Tagged: categories, cut, egen, groups, recode | 2 Comments »
Posted on 19 July 2014 by Mitch Abdon
has recently become a very good friend. For those who (or working with people who) find comfort in working with tables in Excel after data processing or estimation in Stata (yes, there are others who don’t find comfort in this.) and already into Stata 13, learning
could be very helpful (put an end to copy-pasting!). A number of user-written commands, such as
, are also already available for similar purposes. What puts
apart is its ‘user-friendliness’ and flexibility. You can put anything anywhere in Excel without sweat.
Filed under: Basic functions, Basic Programming, Post-estimation | Tagged: excel, foreach, KALAHI-CIDDS, outreg, putexcel, returned results, system variables, tabout | Leave a comment »
Posted on 7 July 2014 by Mitch Abdon
In Reading SPSS data file into Stata
, I describe Sergiy Radyakin’s -usespss- that loads SPSS data (.sav) into Stata. I was on Windows then. -usespss- is unfortunately not available for Mac OS. StatTransfer
could easily do this if you have the software. Another option is to use R.
A quick Google search led me to a simple R routine that does exactly this. Following the steps outlined in Daniel Marcelino’s Loading SPSS (.sav) into Stata
, I managed to covert an SPSS data set I downloaded from IDRA UCLA
website into a Stata .dta file.
Try it out! It is easy to follow.
An interesting extension is Gabriel Rossman’s importspss.ado (requires R)
. It implements the R routine as an ado-file.
Filed under: Data Management | Tagged: r, spss, usespss | Leave a comment »
Posted on 6 May 2014 by Mitch Abdon
If you are Filipino, you are most likely singing the title by now
Looking for a missing bracket, a misplaced comma, or a space that shouldn’t be there—or debugging in general—can be a pain sometimes. When the usual error message fails to point out where you messed up, try turning
on to track down the error.
literally traces the execution of programs. It echoes the lines that Stata executes internally. Reading through the whole thing on your results window can be daunting but you don’t really have to go through those. You just need to know which line it stops executing and see why it stopped there. To turn on
set trace on
And.. don’t forget to turn it off when you don’t need it. They can be really very long.
set trace off
Next time you wonder where you went wrong, use
before you lose your mind. For more options, see
help set trace
Now, continue with the singing.. “what did I do to make you change your mind completely..”
Filed under: Basic Programming | Tagged: debug, do file, trace | 3 Comments »
Posted on 23 April 2014 by Mitch Abdon
If you have been following Statalist (see Stuck? Hello Statalist
), the email-based support system for Stata users, you must have long known that it has moved to a new home and a new format. Statalist is now a forum hosted at Stalist.org
maintained by StataCorp but moderated by a “friendly group” (quoted from the site) of users.
…a forum where Stata users from experts to neophytes maintain a lively dialogue about all things statistical and Stata…
Everyone can browse through the forum but only registered users may participate in the discussions. You may register here
. DON’T forget to read the FAQ
PS They really are nice people until you piss them off 😉
Filed under: Books and websites | Tagged: help, statalist | Leave a comment »