7+ tools to make your Stata life more pleasant Jesse Wursten 1 - - PowerPoint PPT Presentation

7 tools to make your stata life more pleasant
SMART_READER_LITE
LIVE PREVIEW

7+ tools to make your Stata life more pleasant Jesse Wursten 1 - - PowerPoint PPT Presentation

7+ tools to make your Stata life more pleasant Jesse Wursten 1 London SUGM, August 2019 1 Faculty of Economics and Business KU Leuven 1 User-Computer Interaction Four commands that make the computer talk to you sendtoslack cdo


slide-1
SLIDE 1

7+ tools to make your Stata life more pleasant

Jesse Wursten1 London SUGM, August 2019

1Faculty of Economics and Business

KU Leuven 1

slide-2
SLIDE 2

User-Computer Interaction

Four commands that make the computer talk to you

  • sendtoslack
  • cdo
  • stop
  • beep

2

slide-3
SLIDE 3

sendtoslack

Send a message from Stata to your smartphone

  • Stata tells Powershell what to send and who to send it to
  • Powershell sends that info to Slack
  • Slack sends you your message
  • You receive the message on your desktop or smartphone

Some notes

  • Easily integrated in other programs (as you will see)
  • Options can be saved in profjle.do
  • Available on SSC

3

slide-4
SLIDE 4

sendtoslack

4

slide-5
SLIDE 5

cdo

  • do- things with some extra options
  • Send message to phone on success
  • Send message to phone on failure
  • Execute local copy
  • Run program on dofjle end
  • Make log of this run

Some notes

  • Example of sendtoslack being integrated
  • cdo can add timestamps to the logfjle names
  • Available on SSC

5

slide-6
SLIDE 6

cdo

6

slide-7
SLIDE 7

cdo

7

slide-8
SLIDE 8

cdo

8

slide-9
SLIDE 9

cdo

9

slide-10
SLIDE 10

stop

stops a dofjle

  • Can send a message to smartphone
  • Closes log fjles (if you want to)
  • That’s more or less it

Some notes

  • It feels wrong to write errors into my code
  • Available on SSC

10

slide-11
SLIDE 11

stop

11

slide-12
SLIDE 12

beep

Produces a beep

  • Start your dofjle
  • Then add the beep command in the command window

Some notes

  • Requires sound
  • The beep is moderately annoying
  • Built-in

12

slide-13
SLIDE 13

beep

13

slide-14
SLIDE 14

Lazy Programming

Five commands that help the lazy programmer

  • batcher
  • timeit
  • smallfjleversioning
  • censusapi
  • makecode

14

slide-15
SLIDE 15

batcher

Task parallelisation in Stata

  • Give batcher a set of arguments (numlist)
  • Batcher opens a new Stata instance
  • ... runs dofjle with fjrst argument
  • ... opens new Stata, run dofjle with second argument, etc
  • ... reports back when instances fjnish/crash

Some notes

  • Integrated with sendtoslack
  • Requires minor adaptation to dofjle
  • Available on SSC

15

slide-16
SLIDE 16

batcher

16

slide-17
SLIDE 17

batcher

17

slide-18
SLIDE 18

timeit

Single-line timer

  • Prefjx timeit #:
  • Use timer list to obtain results

Some notes

  • You can also give the timers names
  • Also saves incremental timers
  • Available on SSC

18

slide-19
SLIDE 19

timeit

19

slide-20
SLIDE 20

smallfjleversioning (sfv)

Saves old versions of dofjles automatically

  • You tell sfv which folders to watch and how often
  • sfv checks if any of the fjles in there have changed
  • ... if so, it copies those fjles to a different folder
  • ... and names them according to the change date/time

Some notes

  • Very easy to set up
  • Less effort than github or manual duplication
  • Not limited to dofjles
  • Available on Github: http://bit.ly/sfv_sugm

20

slide-21
SLIDE 21

sfv

21

slide-22
SLIDE 22

sfv

22

slide-23
SLIDE 23

censusapi

Accessing the US Census API

  • Hides most of the ‘API’-part behind the scenes
  • Splits the URL into options to make code more readable
  • Allows for P0100001-P0100022 varlist style
  • Splits Census calls of too many variables

Some notes

  • Only tested on Decennial Census and QWI
  • Available on SSC

23

slide-24
SLIDE 24

censusapi

24

slide-25
SLIDE 25

censusapi

25

slide-26
SLIDE 26

makecode

Create structured code blocks

  • Can only explain this in picture

Some notes

  • Meant to be customised
  • Considering move to Powershell
  • Not publicly available (email me)

26

slide-27
SLIDE 27

makecode

27

slide-28
SLIDE 28

makecode

28

slide-29
SLIDE 29

makecode

29

slide-30
SLIDE 30

Bonus tricks

Old tools sometimes work best

  • Windows copy path
  • Label data/variable/values

30

slide-31
SLIDE 31

Any Questions or Suggestions? I highly recommend the Metropolis Theme for Beamer (modifjed version used in this presentation), it can be found at https://github.com/matze/mtheme

31