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: RE: Replacing variable values after using collapse command
From
"Martin Weiss" <[email protected]>
To
<[email protected]>
Subject
RE: st: RE: Replacing variable values after using collapse command
Date
Tue, 6 Jul 2010 00:33:27 +0200
<>
Calls for a different approach, then:
***********
clear*
input double oshpd_fac_no str30 facility_name int snf_medcare_days /*
*/ avg_occupancy_rate byte combined_finance
206071028 "OAK PARK CONVALESCENT HOSPITAL" 351 63.71 0
206071028 "OAK PARK CONVALESCENT HOSPITAL" 1371 75.46 0
206071028 "" 1722 72.506448 1
206371928 "THAT OTHER COMPANY" 355 65.71 0
206371928 "THAT OTHER COMPANY" 1321 75.32 0
206371928 "" 1712 72.5048 0
end
form oshpd_fac_no %9.0f
list, noo
bys oshpd_fac_no: egen maxcomb=max(combined)
bys oshpd_fac_no ( facility_name combined_finance): /*
*/ replace facility_name= facility_name[_N] if maxcomb==1
by oshpd_fac_no: keep if (_n==1 & maxcomb==1) | maxcomb==0
list, noo
***********
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Matthew
Krauchunas
Sent: Dienstag, 6. Juli 2010 00:13
To: [email protected]
Subject: Re: st: RE: Replacing variable values after using collapse command
Thank you that does indeed work. However, is there a way to ensure I
only combine the observations I have identified with the
combined_finance indicator variable? I ask because there are some
observations that I do not want to combine because they have multiple
financial periods due to a change in ownership. I am trying different
"if" commands, but I cannot strike upon the proper one.
Thank you,
Matt
On Mon, Jul 5, 2010 at 5:03 PM, Martin Weiss <[email protected]> wrote:
>
> <>
>
> You may want to use -collapse- again:
>
> ***********
> clear*
>
> input double oshpd_fac_no str30 facility_name int snf_medcare_days /*
> */ avg_occupancy_rate byte combined_finance
> 206071028 "OAK PARK CONVALESCENT HOSPITAL" 351 63.71 0
> 206071028 "OAK PARK CONVALESCENT HOSPITAL" 1371 75.46 0
> 206071028 "" 1722 72.506448 1
> end
>
> form oshpd_fac_no %9.0f
> list, noo
>
> collapse (first) facility_name (lastnm) /*
> */ snf_medcare_days avg_occupancy_rate /*
> */ combined_finance, by(oshpd_fac_no)
>
> list, noo
> ***********
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Matthew
> Krauchunas
> Sent: Montag, 5. Juli 2010 22:56
> To: [email protected]
> Subject: st: Replacing variable values after using collapse command
>
> Hello,
>
> I need advice on how to replace variable values. I have financial
> data that contained more than 1 financial report in a single calendar
> year. With much advice, I have been able to identify and combine
> those periods using the collapse command. I then saved this file and
> combined it with the master file via the append command. My problem
> now though is how to combine the string information in the master
> file with the values obtained after the collapse command. Here is an
> abridged example:
>
> oshpd_fac_no facility_name snf_medcare_days avg_occupancy_rate
> combined_finance
> 206071028 OAK PARK CONVALESCENT HOSPITAL 351 63.71 0
> 206071028 OAK PARK CONVALESCENT HOSPITAL 1371 75.46 0
> 206071028 1722 72.506448 1
>
>
> The oshpd_fac_no is the California assigned id number per PHYSICAL
> address, the facility name is self-explanatory, snf_medcare_days &
> avg_occupancy_rate were two of the variables collapsed respectively,
> and combined_finance is an indicator variable created to show that
> this observation was created via the collapse command. Now the crux
> of the problem....I need to combine the string information from the
> first two variables with the collapsed values in the third
> observation. Thus, it should look like this when finished::
>
> oshpd_fac_no facility_name snf_medcare_days avg_occupancy_rate
> combined_finance
> 206071028 OAK PARK CONVALESCENT HOSPITAL 1722 72.506448 1
>
> Any ideas?
>
> Thank you for all the help thus far!
> Matt
> *
> * 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/
*
* 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/