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 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]

st: forvalues problem


From   Morrison Hodges <hodge002@umn.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: forvalues problem
Date   Sat, 25 Aug 2012 18:19:38 -0500

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 in grpa_jumpnmbr */
local nmbr r(N)             /* gets the number of rows in grpa_jumpnmbr */
sort grpa_jumpnmbr /* sorts grpa_jumpnmbr from lowest to highest */
gen ptile = 0                /* new variable to place percentiles in */
gen dif = 1/`nmbr' /* generates the percentile difference to be added to each row */
replace ptile in 1 = dif    /* lowest number is the lowest percentile */

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 in advance for any help.

Morry Hodges
*
*   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