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:50:46 +0200

<> 

This solution is very ad-hoc-ish:


*************
clear*

inp str10 Data Time
03jan2000   93157
03jan2000   93201
03jan2000   93248
03jan2000   93305
03jan2000   93602
03jan2000   93805
03jan2000   94000
end

compress

gen date=date(Data, "DMY")
form date %td

drop Data

replace Time=floor(Time/100)*100
list, noo

su Time, mean
local min=r(min)
local max=r(max)
save myfile, replace

//generate dataset featuring possible "Time" values
drop _all
set obs `=(round(`max', 1000)-round(`min', 1000))/100+1'

gen Time=round(`min', 1000)+(_n-1)*100
joinby using myfile, unmatched(both) 
drop _merge
so date
replace date=date[1]
so Time
li, noo
*************



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