Announcement

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

  • Date Format

    A simple question:

    How to change the data format to standard STATA format(YYMMDD)?

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str17 Date str6 StartET str22 VisitorNeutral int PTS str22 HomeNeutral int F str9 G str3 H int Attend byte Notes
    "Tue, Oct 27, 2009" "7:30p"  "Boston Celtics"          95 "Cleveland Cavaliers"     89 "Box Score" ""    20562 .
    "Tue, Oct 27, 2009" "8:30p"  "Washington Wizards"     102 "Dallas Mavericks"        91 "Box Score" ""    19871 .
    "Tue, Oct 27, 2009" "10:00p" "Houston Rockets"         87 "Portland Trail Blazers"  96 "Box Score" ""    20403 .
    "Tue, Oct 27, 2009" "10:30p" "Los Angeles Clippers"    92 "Los Angeles Lakers"      99 "Box Score" ""    18997 .
    "Wed, Oct 28, 2009" "7:00p"  "Indiana Pacers"         109 "Atlanta Hawks"          120 "Box Score" ""    17998 .
    "Wed, Oct 28, 2009" "7:00p"  "Philadelphia 76ers"     106 "Orlando Magic"          120 "Box Score" ""    17461 .
    "Wed, Oct 28, 2009" "7:00p"  "Cleveland Cavaliers"     91 "Toronto Raptors"        101 "Box Score" ""    20152 .
    "Wed, Oct 28, 2009" "7:30p"  "Charlotte Bobcats"       59 "Boston Celtics"          92 "Box Score" ""    18624 .
    "Wed, Oct 28, 2009" "7:30p"  "New York Knicks"         93 "Miami Heat"             115 "Box Score" ""    19600 .
    "Wed, Oct 28, 2009" "8:00p"  "New Orleans Hornets"     96 "San Antonio Spurs"      113 "Box Score" ""    18581 .
    "Wed, Oct 28, 2009" "8:00p"  "Sacramento Kings"        89 "Oklahoma City Thunder"  102 "Box Score" ""    18203 .
    "Wed, Oct 28, 2009" "8:00p"  "New Jersey Nets"         93 "Minnesota Timberwolves"  95 "Box Score" ""    18358 .
    "Wed, Oct 28, 2009" "8:00p"  "Detroit Pistons"         96 "Memphis Grizzlies"       74 "Box Score" ""    17212 .
    "Wed, Oct 28, 2009" "10:30p" "Phoenix Suns"           109 "Los Angeles Clippers"   107 "Box Score" ""    15974 .
    "Wed, Oct 28, 2009" "10:30p" "Houston Rockets"        108 "Golden State Warriors"  107 "Box Score" ""    19596 .
    "Wed, Oct 28, 2009" "10:30p" "Utah Jazz"              105 "Denver Nuggets"         114 "Box Score" ""    19155 .
    "Thu, Oct 29, 2009" "8:00p"  "San Antonio Spurs"       85 "Chicago Bulls"           92 "Box Score" ""    21412 .
    "Thu, Oct 29, 2009" "10:30p" "Denver Nuggets"          97 "Portland Trail Blazers"  94 "Box Score" ""    20218 .
    "Fri, Oct 30, 2009" "7:00p"  "New York Knicks"        100 "Charlotte Bobcats"      102 "Box Score" "2OT" 18624 .
    "Fri, Oct 30, 2009" "7:00p"  "Milwaukee Bucks"         86 "Philadelphia 76ers"      99 "Box Score" ""    14638 .
    "Fri, Oct 30, 2009" "7:30p"  "Washington Wizards"      89 "Atlanta Hawks"          100 "Box Score" ""    17079 .
    "Fri, Oct 30, 2009" "8:00p"  "Sacramento Kings"        92 "New Orleans Hornets"     97 "Box Score" ""    17306 .
    "Fri, Oct 30, 2009" "8:00p"  "Orlando Magic"           95 "New Jersey Nets"         85 "Box Score" ""    17525 .
    "Fri, Oct 30, 2009" "8:00p"  "Cleveland Cavaliers"    104 "Minnesota Timberwolves"  87 "Box Score" ""    19356 .
    "Fri, Oct 30, 2009" "8:00p"  "Toronto Raptors"        107 "Memphis Grizzlies"      115 "Box Score" ""    10563 .
    "Fri, Oct 30, 2009" "8:00p"  "Miami Heat"              96 "Indiana Pacers"          83 "Box Score" ""    18165 .
    "Fri, Oct 30, 2009" "8:00p"  "Oklahoma City Thunder"   91 "Detroit Pistons"         83 "Box Score" ""    22076 .
    "Fri, Oct 30, 2009" "8:00p"  "Chicago Bulls"           90 "Boston Celtics"         118 "Box Score" ""    18624 .
    "Fri, Oct 30, 2009" "9:00p"  "Los Angeles Clippers"    98 "Utah Jazz"              111 "Box Score" ""    19911 .
    "Fri, Oct 30, 2009" "10:00p" "Golden State Warriors"  101 "Phoenix Suns"           123 "Box Score" ""    18422 .
    "Fri, Oct 30, 2009" "10:30p" "Dallas Mavericks"        94 "Los Angeles Lakers"      80 "Box Score" ""    18997 .
    "Sat, Oct 31, 2009" "7:00p"  "New Jersey Nets"        104 "Washington Wizards"     123 "Box Score" ""    20173 .
    "Sat, Oct 31, 2009" "7:30p"  "Philadelphia 76ers"     141 "New York Knicks"        127 "Box Score" "OT"  19763 .
    "Sat, Oct 31, 2009" "7:30p"  "Charlotte Bobcats"       79 "Cleveland Cavaliers"     90 "Box Score" ""    20562 .
    "Sat, Oct 31, 2009" "8:30p"  "Portland Trail Blazers" 107 "Houston Rockets"        111 "Box Score" ""    18100 .
    "Sat, Oct 31, 2009" "8:30p"  "Detroit Pistons"         85 "Milwaukee Bucks"         96 "Box Score" ""    15095 .
    "Sat, Oct 31, 2009" "8:30p"  "Sacramento Kings"        94 "San Antonio Spurs"      113 "Box Score" ""    16966 .
    "Sat, Oct 31, 2009" "10:30p" "Dallas Mavericks"        93 "Los Angeles Clippers"    84 "Box Score" ""    13626 .
    end
    Thanks!

  • #2
    Code:
    gen date = daily(substr(Date, 6, .), "MDY")
    format date %tdYYNNDD

    Comment


    • #3
      Thanks a lot!

      Comment

      Working...
      X