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: partial label list


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: partial label list
Date   Wed, 29 Sep 2010 15:45:57 +0000

<>

-list- and -fre- are useful for this purpose, ex:

*******************!
clear

//first, gen 1200 random, fake names//
set obs 1200
forval n = 1/6 {
g i`n' =  char(66+int((122-66+1)*runiform()))
local addv + i`n' `addv'
	}
local addv: subinstr local addv "+ " ""
g namestr = `addv'
drop i*
expand 3 in 1/400
expand 5 in 401/900
expand 6 in 901/1200


//incl.  code from O.P.//
encode namestr, gen(name)
bys name: egen cname = count(name)
label variable cname "count of cases per name"

**********

//list//
bys name: g unique = 1==_n
l namestr name cname if cname>5 & unique==1, nol


//fre//
**-fre- (f. SSC) is useful for this task as well**
cap which fre
if _rc ssc install fre, replace
fre name  if cname>5 using "example1.xls", tab replace all

*******************!

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754
Fax: +979.845.0249
http://ppri.tamu.edu

On Sep 29, 2010, at 9:44 AM, Benhoen2 wrote:

> Stata-sticions,
> 
> I have a string variable ("namestr") that was used to create a integer
> variable ("name").  My dataset has 5000 cases each with a "name" identified.
> The variable "name" has 1,200 unique values and accompanying labels.  I
> created a new variable which stored the rowwise count of each of the names
> across the dataset ("cname").
> 
> Code: 
> encode namestr, gen(name)
> bys name: egen cname = count(name)
> label variable cname "count of cases per name"
> 
> For purposes of display I want to list the name, label, and count for only a
> subset of the list of names (e.g., if cname>5).  I tried playing around with
> "label list" and "tab1" but couldn't find the perfect combo to show me
> everything I wanted.  Any advice?
> 
> Thanks, as always,
> 
> Ben
> 
> 
> *
> *   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/



*
*   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