Announcement

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

  • use using + in range

    Hi Statalist members,

    Is "use using" limited to the last observation ? I was expecting to recovery only my last 5 observations, without needing to load my large dataset entirely in memory.

    Code:
    . clear
    
    . use auto.dta
    (1978 automobile data)
    
    . list make in -5/l
    
         +-------------+
         | make        |
         |-------------|
     70. | VW Dasher   |
     71. | VW Diesel   |
     72. | VW Rabbit   |
     73. | VW Scirocco |
     74. | Volvo 260   |
         +-------------+
    
    . clear
    
    . use make in l using auto.dta
    (1978 automobile data)
    
    . list
    
         +-----------+
         | make      |
         |-----------|
      1. | Volvo 260 |
         +-----------+
    
    . clear
    
    . use make in -5/l using auto.dta
    '-5' invalid observation number
    r(198);
    any clue?

  • #2
    Your expectations were correct and Stata's behavior here is not consistent with the documentation. -in -5/l- is a valid -in-range and should be acceptable to the -use- command in this context. I have verified that the same error occurs in my setup (version 17MP4, Windows 10). I suggest you notify Tech Support--it looks like you have stumbled on a bug.

    In the meantime, you can do this as a workaround:
    Code:
    des using auto.dta
    local cutoff = r(N) - 4
    use make in `cutoff'/l using auto.dta
    Last edited by Clyde Schechter; 08 Aug 2022, 10:57.

    Comment


    • #3
      Ok, Clyde I will proceed notifying Tech Support. Meanwhile I confirm your solution does the trick.

      thks,

      Code:
      . clear
      
      . des using auto.dta
      
      
      . local cutoff = r(N) - 4
      
      . use make in `cutoff'/l using auto.dta
      (1978 automobile data)
      
      . list
      
           +-------------+
           | make        |
           |-------------|
        1. | VW Dasher   |
        2. | VW Diesel   |
        3. | VW Rabbit   |
        4. | VW Scirocco |
        5. | Volvo 260   |
           +-------------+

      Comment

      Working...
      X