Short Notes on Stata (version 10) Data Functions and Stuff



Similar documents
Analysis One Code Desc. Transaction Amount. Fiscal Period

AT&T Global Network Client for Windows Product Support Matrix January 29, 2015

One positive experience I've had in the last 24 hours: Exercise today:

COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) CHARTERED BANK ADMINISTERED INTEREST RATES - PRIME BUSINESS*

COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) CHARTERED BANK ADMINISTERED INTEREST RATES - PRIME BUSINESS*

BCOE Payroll Calendar. Monday Tuesday Wednesday Thursday Friday Jun Jul Full Force Calc

Syntax Menu Description Options Remarks and examples Stored results Also see

Case 2:08-cv ABC-E Document 1-4 Filed 04/15/2008 Page 1 of 138. Exhibit 8

Utility Software II lab 1 Jacek Wiślicki, jacenty@kis.p.lodz.pl original material by Hubert Kołodziejski

Academic Calendar Arkansas State University - Jonesboro

Enhanced Vessel Traffic Management System Booking Slots Available and Vessels Booked per Day From 12-JAN-2016 To 30-JUN-2017

Linux Crontab: 15 Awesome Cron Job Examples

Detailed guidance for employers

SOCIAL ENGAGEMENT BENCHMARK REPORT THE SALESFORCE MARKETING CLOUD. Metrics from 3+ Million Twitter* Messages Sent Through Our Platform

7 Using the Alarm Ready Schedule

Managing Users and Identity Stores

Working with Financial Time Series Data in R

Writing Days and Months

DVMAX Practice v8 - What s New. Using the Appointment Scheduler in DVMAX Practice v8

Date / Time Arithmetic with Oracle

There e really is No Place Like Rome to experience great Opera! Tel: to discuss your break to the Eternal City!

Breen Elementary School

Independent Accountants Report on Applying Agreed-Upon Procedures

BASIC PROGRAMMING GUIDE

MS Visual C++ Introduction. Quick Introduction. A1 Visual C++

Getting Started with Command Prompts

Ashley Institute of Training Schedule of VET Tuition Fees 2015

Nasdaq Dubai TRADING HOLIDAYS AND SETTLEMENT CALENDAR REVISION For Equities Outsourced to the DFM (T+2)

Alcohol. Alcohol SECTION 10. Contents:

Avid Technology, Inc. inews NRCS. inews FTP Server Protocol Specification. Version January 2006

Stock Market Indicators: Historical Monthly & Annual Returns

HALIOTIS Season II (Villas)

Project 2: Bejeweled

Training Assessments Assessments NAEP Assessments (selected sample)

Working with SAS Dates. Stored Value Format Displayed Value

Resource Management Spreadsheet Capabilities. Stuart Dixon Resource Manager

CIMA Interactive Timetable Professional London

ACCESS Nursing Programs Session 1 Center Valley Campus Only 8 Weeks Academic Calendar 8 Weeks

ACCESS Nursing Programs Session 1 Center Valley Campus Only 8 Weeks Academic Calendar 8 Weeks

ACADEMIC CALENDAR June 2016

Box Plots. Objectives To create, read, and interpret box plots; and to find the interquartile range of a data set. Family Letters

Ways We Use Integers. Negative Numbers in Bar Graphs

JAMS 6.X Client Features 3. Working with Jobs 4-5. Submitting Jobs Manually 6-7. Working with Setups 8-9. Working with Views 10-14

Career Planning and Development

Computing & Telecommunications Services Monthly Report March 2015

UNIVERSITY OF DAYTON DAYTON OHIO ACADEMIC CALENDAR

Architectural Services Data Summary March 2011

Introduction To Microsoft Office Excel Bob Booth July 2008 AP-Excel8

Special GREYSTONE COLLEGE Prices for Turkish Students

Human Resources Management System Pay Entry Calendar

Ask your teacher about any which you aren t sure of, especially any differences.


Solution for Homework 2

COPPER GOLD PLATINUM SILVER PALLADIUM

Estuary Time Series Evaluations, Part 1

2016 Examina on dates

3.GETTING STARTED WITH ORACLE8i

Key performance indicators

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

Assignment 4 CPSC 217 L02 Purpose. Important Note. Data visualization

P/T 2B: 2 nd Half of Term (8 weeks) Start: 26-AUG-2013 End: 20-OCT-2013 Start: 21-OCT-2013 End: 15-DEC-2013

P/T 2B: 2 nd Half of Term (8 weeks) Start: 25-AUG-2014 End: 19-OCT-2014 Start: 20-OCT-2014 End: 14-DEC-2014

P/T 2B: 2 nd Half of Term (8 weeks) Start: 24-AUG-2015 End: 18-OCT-2015 Start: 19-OCT-2015 End: 13-DEC-2015

Welcome! First Steps to Achieving Effective Inventory Management

Throughput and Outstanding Workload for High Court Criminal Jury Trials - August 2005 to July 2006

2015 Examination dates

Five Ways Student Loans Impact Credit. Federal Student Loans are Unique. Federal Student Loans are Unique

Micros Troubleshooting & Error Message Guide.

Downloading Your Financial Statements to Excel

UNIVERSITY OF DAYTON DAYTON OHIO ACADEMIC CALENDAR (Subject to Change)

Interest Rates. Countrywide Building Society. Savings Growth Data Sheet. Gross (% per annum)

MLA FORMAT A Guide to Preparing Note Cards and Bibliography Cards

Footswitch Controller OPERATING INSTRUCTIONS

2009 Ryder Scott Reserves Conference Evaluation Challenges in a Changing World First of the Month Prices.How hard can that be to get right?

SDHNS 3 Hour English Food Handlers Class

START HERE THE BASICS TIPS + TRICKS ADDITIONAL HELP. quick start THREE SIMPLE STEPS TO SET UP IN UNDER 5 MINUTES

URL encoding uses hex code prefixed by %. Quoted Printable encoding uses hex code prefixed by =.

Basic numerical skills: FRACTIONS, DECIMALS, PROPORTIONS, RATIOS AND PERCENTAGES

Interest rate Derivatives

Project Management Planning

Important Tips when using Ad Hoc

TELEPHONE SYSTEM F.A.Q.

Economic indicators dashboard

The Standardized Precipitation Index

WORKING WITH SAS DATE AND TIME FUNCTIONS Andrew H. Karp Sierra Information Services, Inc. San Francisco, California USA

Maternity Allowance. Notes sheet. Please keep these notes for your information, do not return them with your MA1 claim form.

Proposal to Reduce Opening Hours at the Revenues & Benefits Coventry Call Centre

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

CAFIS REPORT

Stata Tutorial. 1 Introduction. 1.1 Stata Windows and toolbar. Econometrics676, Spring2008

2016 BELMONT PARK SPRING / SUMMER MEET POST TIMES/WAGERING MENU

HOLY GHOST CATHOLIC SCHOOL

Business Idea Development Product production Services. Development Project. Software project management

Time Recorder. User Manual. PDF created with FinePrint pdffactory trial version

S5 Information Systems Time Line

A Resource for Free-standing Mathematics Units. Data Sheet 1

2016 BELMONT PARK SPRING / SUMMER MEET POST TIMES/WAGERING MENU

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

What's New in ADP Reporting?

Transcription:

Monday, October 20, 2008 Short Notes on Stata (version 10) Data Functions and Stuff How Stata records dates and times Dates and times are called %t values. %t values are numerical and integral. The integral value records the number of time units that have passed from an agreed-upon base, which for Stata is 1960. Coding and interpretation of date and time (%t) values are as follows: +---------------------------------------------------------------------+ ----- Numerical value & interpretation ------ Format Meaning Value = -1 Value = 0 Value = 1 --------+------------+---------------+---------------+--------------- %td days 31dec1959 01jan1960 02jan1960 ----------------------------------------------------------------------- For a %td value, a 1-unit change represents 1 day. Integer 4,569 represents 05jul1972 because that date occurred 4,569 days after 01jan1960. Integer -4,569 represents 29jun1947 because that date occurred 4,569 days before 01jan1960. Inputting date and time data Date and time variables are best read as strings. Then use one of the string-to-numeric conversion functions to convert the string representation to the appropriate %t value: Format String-to-numeric conversion function -------+----------------------------------------- %td date(string, mask) %tw weekly(string, mask) %tm monthly(string, mask) %ty yearly(string, mask) %tg no function necessary; read as numeric ------------------------------------------------- In the above functions, string is the variable or value containing the string representation to be converted and mask specifies the order in which the components occur: For %td function date(), string might be "August 21, 2005" or "8-21- 2005" and mask might be "MDY", meaning that the elements occur in the order month, day, and year.

Constructing date and time values from numerical components If you had numeric variables M, D, and Y containing month number, day of month, and year (in the first observation, the variables might contain 12, 15, and 2006), you could code. generate mydate = mdy(m, D, Y) to obtain new %td variable containing the date (which would be 15dec2006 in the first observation). The date-from-numerical-components functions are where Format Function -------+------------------------------------------ %td mdy(m, D, Y) -------------------------------------------------- td is a %td value, M, D, and Y are month, day, and year values, 1 <= M <= 12 1 <= D <= 31 0100 <= Y <= 9999 2

Formatting date and time values A variable's values are formatted to indicate (1) the units used and (2) how the variable is to be displayed:. generate mydate = date(datestr, "DMY"). list mydate in 1 +--------+ mydate -------- 1. 17096 +--------+. format mydate %td. list mydate in 1 +-----------+ mydate ----------- 1. 22oct2006 +-----------+ The %t formats result in the following output: Format Example of output -------+---------------------------- %td 05jul1972 ------------------------------------ You can specify how date and times are to be formatted. Rather than 05jul1972, you could have July 5, 1972, or rather than 05jul1972 21:38:02, you could have 7-5-72 9:38 p.m. This reformatting is done by adding codes to the end of %tc, %tc, %td, etc. In fact, the default %tc, %tc, %td,..., formats actually mean Format Implied (fully specified) format -------+--------------------------------- %td %tdddmonccyy ----------------------------------------- 3

The formatting codes are Code Meaning Output ----------------------------------------------------------- CC century-1 01-99 cc century-1 1-99 YY 2-digit year 00-99 yy 2-digit year 0-99 JJJ day within year 001-366 jjj day within year 1-366 Mon month Jan, Feb,..., Dec Month month January, February,..., December mon month jan, feb,..., dec month month january, february,..., december NN month 01-12 nn month 1-12 DD day within month 01-31 dd day within month 1-31 DAYNAME day of week Sunday, Monday,... (aligned) Dayname day of week Sunday, Monday,... (unaligned) Day day of week Sun, Mon,... Da day of week Su, Mo,... day day of week sun, mon,... da day of week su, mo,... h half 1-2 q quarter 1-4 WW week 01-52 ww week 1-52 am show am or pm am or pm a.m. show a.m. or p.m. a.m. or p.m. AM show AM or PM AM or PM A.M. show A.M. or P.M. A.M. or P.M.. display period., display comma, : display colon : - display hyphen - _ display space / display slash / \ display backslash \ + separator (see note) ----------------------------------------------------------------- 4

Experimenting with the date and time functions The best way to become familiar with Stata's date and time functions is to experiment with the display command.. display date("5-12-1998", "MDY") 14011. display %td date("5-12-1998", "MDY") 12may1998 Remember, when you work with display, you can specify a format in front of the expression to specify how the result is to be formatted. Translating run-together dates such as 20060125 Functions clock(), Clock(), and date() will translate dates and times that are run together such as 20060125, 060125, and 20060125110215 (which is 25jan2006 11:02:15). There is nothing special that you haveto do:. display %d date("20060125", "YMD") 25jan2006. display %td date("060125", "20YMD") 25jan2006. display %tc clock("20060125110215", "YMDhms") 25jan2006 11:02:15 In a data context, you could type. gen startdate = date(startdatestr, "YMD"). gen double starttime = clock(starttimestr, "YMDhms") Remember to read the original data into a string. If you read the data as numeric, the best advice is to read the data again. Numbers such as 20060125 and 20060125110215 will be rounded unless they are stored as doubles. 5

6

7