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 |
Nick Cox <njcoxstata@gmail.com> |

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

Subject |
Re: st: forvalues problem |

Date |
Sun, 26 Aug 2012 07:50:53 +0100 |

Several errors here: 1. Evaluate r(N): local nmbr = r(N) Otherwise you are just copying the text "r(N)", not a good idea.

local back = ptile['i' - 1]

These are the syntax or style errors evident on a quick reading.

and support -if- and -in-.

Nick On 26 Aug 2012, at 00:19, Morrison Hodges <hodge002@umn.edu> wrote:

I have the following code: ---------------------------------- /* cdp.do Creating a cumulative distribution plot for use in PreFib analysis Created by MH on Friday, August 23, 2012 */ version 12.1 capture log close set more off use prefib.dta, clear label data "PreFib Data"summarize grpa_jumpnmbr /* to get the number of rows ingrpa_jumpnmbr */local nmbr r(N) /* gets the number of rows ingrpa_jumpnmbr */sort grpa_jumpnmbr /* sorts grpa_jumpnmbr from lowest tohighest */gen ptile = 0 /* new variable to place percentiles in*/gen dif = 1/`nmbr' /* generates the percentile differenceto be added to each row */replace ptile in 1 = dif /* lowest number is the lowestpercentile */forvalues i = 2/`nmbr' { local back = (ptile in (`i' - 1)) replace ptile in `i' = back + dif } log close ---------------------------------------I get a syntax error with this, but I don't know why. Thanks inadvance for any help.

* * 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: forvalues problem***From:*Morrison Hodges <hodge002@umn.edu>

- Prev by Date:
**re: Re: st: factor variables and qreg?** - Next by Date:
**Re: st: RE: FW: Running Polychoric Principal Component Analysis in STATA** - Previous by thread:
**st: forvalues problem** - Index(es):