Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: AW: Forvalues [was cut function]


From   "Dr. Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Forvalues [was cut function]
Date   Tue, 3 Aug 2010 17:59:36 +0200

<> 

" I tried to give Stata this command:

forval data: 03jan2000/24feb2000{
gen time2=93000 (1) 94000
}

The command doesn't work."




You want to read up on some of the problems with your command in NJC´s seminal http://www.stata-journal.com/sjpdf.html?articlenum=pr0005. The colon is misplaced, btw. 



If all you wanted was what your code above implies, you could just



***********
clear*
set obs `=date("24feb2000", "DMY")-date("03jan2000", "DMY")+1'
gen data=date("02jan2000", "DMY")+_n
format data %td

expand 11
bys data: gen time2=92900+_n*100
l, noo sepby(data) h(20)
***********

However, your prior example implied that you wanted two entries of, say, "93200", for the original entries "93201" and "93248", which makes the whole thing more difficult. Hence my earlier "cumbersome" solution...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Katia Bobulova
Gesendet: Dienstag, 3. August 2010 17:27
An: [email protected]
Betreff: st: Forvalues [was cut function]

Dear all,

I am still trying to solve my problem to have equal time intervals for
each data.

This is what I have:

   Data            Time
03jan2000       93157
03jan2000       93201
03jan2000       93248
03jan2000       93305
03jan2000       93602
03jan2000       93805
03jan2000       94000

And this is what I want to obtain:

   Data            Time
03jan2000       93000
03jan2000       93100
03jan2000       93200
03jan2000       93200
03jan2000       93300
03jan2000       93400
03jan2000       93500
03jan2000       93600
03jan2000       93700
03jan2000       93800
03jan2000       93900
03jan2000       94000

I thought that a possibler solution would be to construct a variable
with all the time intervals for each data.

I tried to give Stata this command:

forval data: 03jan2000/24feb2000{
gen time2=93000 (1) 94000
}

The command doesn't work.

Do you know if this could a possible solution to my problem and if
yes, how to write the right code?

Thank you very much.

Katia
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index