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]

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: RE: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID |

Date |
Sun, 19 Sep 2010 21:36:59 +0200 |

<> I bet there is a much more elegant solution out there, but this one works: *********** clear* inp byte(ID PanelVar) str8 TimeVar /* */ byte NumVisit 1 2 "3/6/2004" 12 2 8 "3/7/2004" 8 3 3 "8/7/2005" 6 end //expand the thing expand NumVisit so ID l, noo sepby(ID) //monthly data split TimeVar, parse(/) gen monthlydate=monthly(TimeVar1+" "+TimeVar3, "MY") //add two months bys ID: replace monthlydate=monthlydate[1]+2*(_n-1) //get TimeVar back replace TimeVar= string(month(dofm(monthlydate)))+"/"+ /* */ TimeVar2+"/"+string(year(dofm(monthlydate))) l, noo sepby(ID) *********** HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss Sent: Sonntag, 19. September 2010 20:25 To: statalist@hsphsun2.harvard.edu Subject: st: RE: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID <> Just *********** expand NumVisit *********** HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Emma Quinn Sent: Sonntag, 19. September 2010 20:14 To: statalist@hsphsun2.harvard.edu Subject: st: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID Hi, I am working with panel data, and I would like to append observations to my time series variable. However, the number of observations I would like to add depends on the ID of the subject and is equal to another variable in my dataset; the number of appointments they have made. The appointments for each would be made on two-month intervals following the starting date--the time variable. I would like to add 2 month intervals for each ID; however the number of 2 month intervals I add depends on how many visits they ended up making. For example if : ID Panel Var Time Var NumVisit 1 2 3/6/2004 12 2 8 3/7/2004 8 3 3 8/7/2005 6 then for ID 3, I would like to generate the date variable 10/7/2005, 12/7/2005, 2/7/2005, 4/7/2005, 6/7/2005 and 8/7/2005. I tried to tsappend add(), after defining a local macro x = NumVisit and again as local macro 4 = NumVisit but they didn't work; the command would not recognize 'x' or '4' as a positive integer. Alternatively, my time variable corresponds to the "start date" of the study. I have another date variable that corresponds to the "end date"--the last visit made. If any one knew how to generate two month intervals between the two dates, where the start and end date are different for each ID, that would be much appreciated. Much appreciated! * * 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/ * * 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/

**References**:**st: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID***From:*Emma Quinn <e.q.jackson@gmail.com>

**st: RE: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**st: RE: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID** - Next by Date:
**st: -set mem- allows allocating more memory only after a few trials** - Previous by thread:
**st: RE: Fwd: Adding Observations to PanelDta; Number Obs Equal to Another Variable, varying for each ID** - Next by thread:
**st: -set mem- allows allocating more memory only after a few trials** - Index(es):