Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Clarification of prior message


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: Clarification of prior message
Date   Wed, 23 Oct 2002 15:26:12 -0400

You need Nick Cox's -split-, and -reshape-:

	ssc install split		
	split nmi, gen(name) parse(";")
	reshape long name , i(wku) 
	drop if name==""
	drop _j nmi
	rename name nmi

Explanation:

-ssc install- installs the -split- program, if you don't already have
it.

-split- splits apart your nmi variable, into a set of variables called
name1, name2, and so on, splitting on the semicolon.

-reshape- then changes the dataset so there is one observation per
inventor, instead of one per invention.  As a side effect, this creates
blank inventor records whenever an invention has fewer than the maximum
number of inventions.  

-drop if name==""- gets rid of thoseblank inventor records

-drop- gets rid of the variable _j created by -reshape-, and the
original nmi variable.

-rename- renames the variable name to nmi.

Voila.

Nick Winter

> -----Original Message-----
> From: Hoetker, Glenn [mailto:[email protected]] 
> Sent: Wednesday, October 23, 2002 3:14 PM
> To: [email protected]
> Subject: st: Clarification of prior message
> 
> 
> Until I got a received the copy of the message I just sent 
> out, I didn't
> realize how the formatting could get messed up.  Since that could make
> the nature of my problem somewhat unclear, let me repost it, with some
> slight reformatting.  My apologies for any possible confusion. --Glenn
> 
> ----
> 
> 
> Hoping someone can help me with a problem involving dividing up a
> variable. My data consists of patent numbers (wku) and inventors (nmi)
> and looks like this:
> 
> Record 1
> NMI: Schmitt, Ty; Gandre, Jerry   WKU: 5586003
> 
> Record 2
> NMI: Sato, N. Albert; Baker, David C.; Waldron, Christie J.	  WKU:
> 5586324
> 
> Record 3
> NMI: Swamy, N. Deepak	WKU: 5587885
> 
> I would like it to look like this:
> 
> nmi				wku 
> Schmitt, Ty 		5586003
> Gandre, Jerry		5586003
> Sato, N. Albert 		5586324
> Baker, David C. 		5586324
> Waldron, Christie J.	5586324
> Swamy, N. Deepak		5587885
> 
> That is, I want to create a record containing each inventor and his or
> her associated patent number.  If Ty Schmitt had five 
> patents, he should
> show up in five records.  The number of inventors per patent 
> varies from
> one to many.
> 
> I've looked for egen functions (and their extensions) and done some
> experimenting, but am floundering.  Any help would be very 
> appreciated!
> 
> Glenn H.
> 
> Glenn Hoetker
> Assistant Professor of Strategy
> Department of Business Administration
> University of Michigan at Urbana-Champaign
> 217-355-4891
> [email protected]
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index