+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 16 to 20 of 20

Thread: Problems with reshaping data

  1. #16
    Points: 443, Level: 8
    Level completed: 86%, Points required for next Level: 7

    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Problems with reshaping data



    I am trying to understand your code. I know what you're doing, but what does the r(mean)-command?

    forvalues i=1(1)666 {
    sum Tradedattheend if Prouctid==`i'
    qui replace Tradedattheend=1 if r(mean)>0 & Productid==`i'
    }

  2. #17
    Points: 1,620, Level: 23
    Level completed: 20%, Points required for next Level: 80

    Location
    Sweden
    Posts
    199
    Thanks
    11
    Thanked 45 Times in 41 Posts

    Re: Problems with reshaping data

    After running a sum-command the mean is being saved as a scalar. r(mean) is that scalar. So in your case r(mean) is equal to the mean of Tradedattheend for product `i'.

  3. #18
    Points: 443, Level: 8
    Level completed: 86%, Points required for next Level: 7

    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Problems with reshaping data

    Englund, could plz take a look at another problem i face?

    http://www.talkstats.com/showthread....cts?highlight=

    I can't get what I want. I hope you could help me in the right direction. thx

  4. #19
    RoboStataRaptor
    Points: 7,341, Level: 56
    Level completed: 96%, Points required for next Level: 9
    bukharin's Avatar
    Location
    Sydney, Australia
    Posts
    1,018
    Thanks
    9
    Thanked 240 Times in 233 Posts

    Re: Problems with reshaping data

    Quote Originally Posted by Statahulk View Post
    I created t to sort on date since date is a string variable. Furthermore, I sorted by productid.
    I've been on leave but wanted to come back to this thread to make this comment - the above is NOT how to handle sorting on date. Instead you should convert your string date to a Stata formatted date using the date() function. For example:
    gen mydate=date(Date, "MDY")
    format %td mydate

    Then you can sort on mydate, use mydate for time-series commands etc etc.

  5. #20
    Points: 443, Level: 8
    Level completed: 86%, Points required for next Level: 7

    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Problems with reshaping data


    Thank you for your advice bukharin. Could you plz look at my other question?
    http://www.talkstats.com/showthread....cts?highlight=
    I am still struggling with this problem, can't really get what i want.
    I hope you have an idea.

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats