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]

[no subject]



<>

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

Ben Hoen
Office: 845-758-1896
Cell: 718-812-7589
[email protected]

-----Original Message-----
From: Benhoen2 [mailto:[email protected]] 
Sent: Wednesday, September 29, 2010 10:44 AM
To: '[email protected]'
Subject: partial label list

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index