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, is already up and running.

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

st: forvalues problem

From   Morrison Hodges <>
Subject   st: forvalues problem
Date   Sat, 25 Aug 2012 18:19:38 -0500

I have the following code:

    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:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index