Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please, how mark the first or last case time variable. Thanks

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int id float(date_dx time)
    1 16875 1
    1     . 2
    1     . 3
    1     . 4
    1     . 5
    2 16967 1
    2     . 2
    2     . 3
    2     . 4
    2     . 5
    3 13680 1
    3     . 2
    3     . 3
    3     . 4
    3     . 5
    end
    format %dM_d,_CY date_dx
    ------------------ copy up to and including the previous line ------------------



  • #2
    your question is not completely clear to me, but here I add 2 variables: first and last:
    Code:
    . bys id (time): gen byte first=id!=id[_n-1]
    
    . bys id (time): gen byte last=id!=id[_n+1]
    
    . li, clean noo
    
        id          date_dx   time   first   last  
         1   March 15, 2006      1       1      0  
         1                .      2       0      0  
         1                .      3       0      0  
         1                .      4       0      0  
         1                .      5       0      1  
         2    June 15, 2006      1       1      0  
         2                .      2       0      0  
         2                .      3       0      0  
         2                .      4       0      0  
         2                .      5       0      1  
         3    June 15, 1997      1       1      0  
         3                .      2       0      0  
         3                .      3       0      0  
         3                .      4       0      0  
         3                .      5       0      1
    you can of course label the new variables if you want; see
    Code:
    help label

    Comment


    • #3
      Thank you !!!!. My problem is completely solved. It has helped me a lot !!!

      Comment

      Working...
      X