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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: most requested *simple* features to help SPSS users transition


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: most requested *simple* features to help SPSS users transition
Date   Fri, 19 Oct 2012 16:18:59 +0100

program nicecode
version 8
syntax varlist [if] [in], Generate(str) [Missing]
egen `generate' = group(`varlist') `if' `in', `missing' label
end


On Fri, Oct 19, 2012 at 4:16 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> On (1), I think this has been mentioned at recent users' meetings and
> I imagine wildly that StataCorp take it seriously.
>
> On (2), see -tabchi- and -tabchii- from -tab_chi- (SSC) for a partial answer.
>
> On (3), see -egen-'s -group()- function with -label()- option and
>
> SJ-7-4  dm0034  . . . Stata tip 52: Generating composite categorical variables
>         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
>         Q4/07   SJ 7(4):582--583                                 (no commands)
>         tip on how to generate categorical variables using
>         tostring and egen, group()
>
> It would be easy to code up a friendly wrapper for this. Note that it
> works just to clean up a single variable.
>
> . sysuse auto, clear
>
> . program nicecode
>   1.         version 8
>   2.         syntax varlist [if] [in], Generate(str) [Missing]
>   3.         egen `generate' = group(`varlist'), `missing' label
>   4. end
>
> .
> end of do-file
>
> . nicecode foreign rep78, gen(mycatvar)
> (5 missing values generated)
>
> . tab mycatvar
>
> group(forei |
>   gn rep78) |      Freq.     Percent        Cum.
> ------------+-----------------------------------
>  Domestic 1 |          2        2.90        2.90
>  Domestic 2 |          8       11.59       14.49
>  Domestic 3 |         27       39.13       53.62
>  Domestic 4 |          9       13.04       66.67
>  Domestic 5 |          2        2.90       69.57
>   Foreign 3 |          3        4.35       73.91
>   Foreign 4 |          9       13.04       86.96
>   Foreign 5 |          9       13.04      100.00
> ------------+-----------------------------------
>       Total |         69      100.00
>
>
>
>
> Nick
>
> On Fri, Oct 19, 2012 at 3:43 PM, JVerkuilen (Gmail)
> <jvverkuilen@gmail.com> wrote:
>> Having decided to use Stata instructionally I run into a few little
>> things that would be nice and, to my knowledge, don't exist. Slowly
>> but surely the students here are switching over as they realize they
>> need to learn things like propensity scoring. In all honesty I don't
>> care what they do when they grow up, but it greatly simplifies my life
>> not to have to deal with SPSS. However there are some little things
>> that turn out to be resistance-causing on the part of folks used to
>> it:
>>
>> (1) A simple way to clear the Results window. -clear- nukes the data
>> in memory. An easy workaround is simply to hold the return key down
>> for a goodly bit of time, but a way to get a clean results window
>> would be very nice.
>>
>> (2) -tabulate- could use a few more options. For instance, it doesn't
>> generate cell residuals or adjusted residuals, or compute odds ratios.
>> -cc- runs the latter but other people use odds ratios and
>> Mantel-Haenszel tests too and won't necessarily think to look under
>> Tables for Epidemiologists. ;)
>>
>> (3) SPSS has one "killer app": Data management in it is quite nice.
>> For instance, "automatic recode" is monumentally convenient. This
>> takes a variable, automatically creates a new one with sequential
>> numbers and labels it with the values of the old variables. The
>> variable can be big 'n nasty, like a string with hundreds of unique
>> entries. The ability to do things like paste labels and so on is also
>> handy, though it may go against the general philosophy of careful
>> tracing of all changes to data.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index