Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: FW: Urgent: Stored Data after the calculation


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: FW: Urgent: Stored Data after the calculation
Date   Sun, 28 Mar 2010 21:44:45 +0200

<>

Several things are getting mixed up here, and I hope I am not the source of
the confusion. The -local- line stands on its own, unencumbered by what you
typed before. I thought you only wanted to see the value of A09 for which
the -if- expression was true, hence my answer. 

Where does the "=r(N)" part come from? It sounds suspiciously like a line
being taken out of context. This very context might have been a prior line
containing the -count- command, possibly augmented by an -if- expression of
the kind you had in mind. This command would leave an r-return value in its
wake, which you could then put into a -local-...


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of keeler james
Sent: Sonntag, 28. März 2010 21:38
To: statalist@hsphsun2.harvard.edu
Subject: RE: st: FW: Urgent: Stored Data after the calculation

Ta, Martin.

After the command:

 list if Cohort=="Group 2" & A09!=.

I don't think I can use the command:

local second=A09[2]

anymore, I try to use the following

local second=r(N)

but it doesn't seem to work. Ummm...

Cal

----------------------------------------
> From: martin.weiss1@gmx.de
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: FW: Urgent: Stored Data after the calculation
> Date: Sun, 28 Mar 2010 20:39:30 +0200
>
>
> <>
>
>
> Maybe you wanted:
>
> *******
> list if Cohort=="Group 2" & A09!=.
> *******
>
> The string "and" was bound to cause an error message...
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of keeler james
> Sent: Sonntag, 28. März 2010 20:34
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: FW: Urgent: Stored Data after the calculation
>
> BTW, one more question.
>
> What if the groups are ever changing, e.g. sometimes groups 1 and 4 are
> missing, and it will end up like the following:
>
> Cohort Tot08 Tot09 A08 A09
>
> Group 2 10   3     0
> ?
> Group 3 3    4     2    ?
> Group 5 3
> 8     0    ?
> Group 6 0    31    0    ?
> Group 7 266  245   181  ?
>
> if we use the same display command -di in r "Second value of A09: "
A09[2]-,
> it will show the value of Group 3 instead of Group 2.
>
> I try in vain to use the following command
>
> di in r if Cohort=="Group 2" and A09!=.
>
> to lock the output to Group 2 but there was an error message. Any help
will
> be great!
>
> Cal
>
> ----------------------------------------
>> From: keelercalchas@hotmail.com
>> To: statalist@hsphsun2.harvard.edu
>> Subject: RE: st: FW: Urgent: Stored Data after the calculation
>> Date: Sun, 28 Mar 2010 17:15:45 +0100
>>
>> Brilliant! Many thanks, Martin - have a good weekend!
>>
>> Cal
>>
>>> From: martin.weiss1@gmx.de
>>> To: statalist@hsphsun2.harvard.edu
>>> CC: keelercalchas@hotmail.com
>>> Subject: st: FW: Urgent: Stored Data after the calculation
>>> Date: Sun, 28 Mar 2010 16:02:07 +0200
>>>
>>>
>>> <>
>>>
>>>
>>> Try this, and switch your mail program to text only... All of this is
>>> discussed in [U], sect. 13.7...
>>>
>>> *******
>>> clear*
>>>
>>> input str7 Cohort int(Tot08 Tot09 A08)
>>> "Group 1" 48 66 17
>>> "Group 2" 10 3 0
>>> "Group 3" 3 4 2
>>> "Group 4" 1 0 0
>>> "Group 5" 3 8 0
>>> "Group 6" 0 31 0
>>> "Group 7" 266 245 181
>>> end
>>>
>>> gen A09=round((A08/Tot08)*Tot09)
>>>
>>> list, noo
>>>
>>> di in r "First value of A09: " A09[1]
>>> di in r "Second value of A09: " A09[2]
>>> di in r "Double the first value of A09: " 2*A09[1]
>>>
>>> *store second value in a -local-
>>> local second=A09[2]
>>> di in r `second'
>>> *******
>>>
>>>
>>> HTH
>>> Martin
>>>
>>> From: keeler james [mailto:keelercalchas@hotmail.com]
>>> Sent: Sonntag, 28. März 2010 15:10
>>> To: martin.weiss1@gmx.de; statalist@hsphsun2.harvard.edu
>>> Subject: FW: Urgent: Stored Data after the calculation
>>>
>>> Hi Martin,
>>>
>>> Thanks for the prompt response.
>>>
>>> The message attached is my original request, which got bounced back:
>>>
>>> For Group1, the calculated value for A09 is 23.4; for Group2, the
> calculated
>>> value is 0 and so on for the rest of the groups. But how can I reuse
23.4
>>> (Group 1, A09) in one specific (further) calculation and 0 (Group2, A09)
> in
>>> a separate (further) calculation?
>>>
>>> I think it should be quite easy, but I just don't know how to do that.
>>>
>>> Calchas
>>> ________________________________________
>>> From: keelercalchas@hotmail.com
>>> To: statalist@hsphsun2.harvard.edu
>>> Subject: FW: Urgent: Stored Data after the calculation
>>> Date: Sat, 27 Mar 2010 00:06:41 +0000
>>>
>>> Dear Statalist,
>>>
>>> I have the following table with column "A09" needed to be calculated.
>>>
>>> Cohort Tot08 Tot09 A08 A09
>>>
>>> Group 1 48 66 17 ?
>>> Group 2 10 3 0 ?
>>> Group 3 3 4 2 ?
>>> Group 4 1 0 0 ?
>>> Group 5 3 8 0 ?
>>> Group 6 0 31 0 ?
>>> Group 7 266 245 181 ?
>>>
>>> I use the command:
>>>
>>> gen A09=round((A08/Tot08)*Tot09)
>>>
>>> This will work well for the missing column "A09", but how can I reuse
the
>>> calculated numbers to do further calculations?
>>>
>>> I know it is something relating to the command of stored data, i.e.:
>>>
>>> local missing=r(N)
>>>
>>> but this is only for a scalar value, what about saving and reusing the
>>> entire column? Really stuck at the moment and any help will be
> appreciated.
>>>
>>> Ta,
>>> Calchas
>>>
>>>
>>> ________________________________________
>>> Do you have a story that started on Hotmail? Tell us now
>>> ________________________________________
>>> Do you want a Hotmail account? Sign-up now - Free
>>> ________________________________________
>>> Do you have a story that started on Hotmail? Tell us now
>>> ________________________________________
>>> Got a cool Hotmail story? Tell us now
>>>
>>>
>>> *
>>> * 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/
>>
>> _________________________________________________________________
>> Send us your Hotmail stories and be featured in our newsletter
>> http://clk.atdmt.com/UKM/go/195013117/direct/01/
>> *
>> * 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/
>
> _________________________________________________________________
> Send us your Hotmail stories and be featured in our newsletter
> http://clk.atdmt.com/UKM/go/195013117/direct/01/
> *
> * 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/
 		 	   		  
_________________________________________________________________
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us
now
http://clk.atdmt.com/UKM/go/195013117/direct/01/
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index