Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: st. "for" command in stata X


From   "Dherani, Mukesh" <M.K.Dherani@liverpool.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: st. "for" command in stata X
Date   Thu, 19 Jun 2008 15:38:08 +0100

Hi all,
I am trying to recode missing values to 0 as I used to in stata 8 using 'for x in any' but stata 9 is not accepting it. I am using foreach using following command but it is returning with error. Please help.
Thanks,

foreach var in varlist fwauri1 fwauri2 fwauri3 fwauri4 {
			recode varlist .=0
}


BW,m

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Shehzad Ali
Sent: 19 June 2008 14:01
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: maximum 3 and minmium 3 values

Thanks, Martin. - rowsort - does the trick, though the issue of missing
values is a pain but I can live with that. 

Thank you again.

Shehzad


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: 19 June 2008 13:29
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: RE: RE: RE: maximum 3 and minmium 3 values

Actually, you got my suggestion right, but with 15.000 obs it is admittedly
not feasible. I bet other listers will provide a better suggestion. 
Note, though, that -ssc d rowsort- can sort for each observation. After that
-keep- only the first three and last three columns and you have a perfect
dataset with your desired results...

Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Shehzad Ali
Sent: Thursday, June 19, 2008 2:26 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: RE: RE: maximum 3 and minmium 3 values

Thanks, Martin. In the xpose file, do you mean I should sort for each column
separately? If this is the case, then it will take forever with my 15,000
observations. Maybe I misunderstood your suggestion.

Shehzad


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: 19 June 2008 12:17
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: RE: maximum 3 and minmium 3 values

Admittedly, I jumped to an early conclusion as -egen- gives you the min and
max per observation, but you asked for the three smallest and largest
values. You could -save- your data, then -xpose, clear- which leaves you
with columns representing observations in the original data. Then -sort-
according to each column and extract the three highest and lowest values
into a -postfile-. Other listers may be aware of packages that automate this
task...

Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Thursday, June 19, 2008 12:50 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: maximum 3 and minmium 3 values

-egen , rowmin-
-egen , rowmax-

Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Shehzad Ali
Sent: Thursday, June 19, 2008 12:50 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: maximum 3 and minmium 3 values

Hi listers,

I have a dataset with 11 variables for which I want to find out maximum 3 
and minimum 3 values for each observation. I am aware that we can use 
max(x1, x2..., xn) to get the first maximum or similarly first minimum. 
Please advise on how to get subsequent maximum and minimum values.

Thanks,

Shehzad

*
*   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/

*
*   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/

*
*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index