magics

IPython magics for nbstata

source

StataMagics

 StataMagics ()

Class for handling magics

test_instance = StataMagics()
test_eq(test_instance._unabbrev_magic_name("*%non_name"), "*%non_name")
test_eq(test_instance._unabbrev_magic_name("%%se"), "%%se")
test_eq(test_instance._unabbrev_magic_name("%br"), "%browse")

source

StataMagics._parse_code_for_magic

 StataMagics._parse_code_for_magic (code)
test_instance = StataMagics()
test_eq(test_instance._parse_code_for_magic("%browse"), ('%browse', ""))
test_eq(test_instance._parse_code_for_magic("*%browse"), ('%browse', ""))
test_eq(test_instance._parse_code_for_magic("*%br"), ('%browse', ""))
test_eq(test_instance._parse_code_for_magic("*%browse,"), ('%browse', ","))
test_fail(test_instance._parse_code_for_magic, args=("*%blah\nreg var1"))
test_fail(test_instance._parse_code_for_magic, args=("*%se echo=True"))
test_instance._parse_code_for_magic("*%browse in 1/10")
('%browse', 'in 1/10')
''.isspace()
False

source

StataMagics.magic

 StataMagics.magic (code, kernel, cell)

source

StataMagics.magic_locals

 StataMagics.magic_locals (code, kernel, cell)
_get_new_settings("echo = True")
{'echo': 'True'}
_get_new_settings("""
/*
missing = NOTHING
echo = False
*/""")
{'missing': 'NOTHING', 'echo': 'False'}

source

StataMagics.magic_set

 StataMagics.magic_set (code, kernel, cell)

Browse magic


source

StataMagics.magic_browse

 StataMagics.magic_browse (code, kernel, cell)

Display data interactively.


source

Frame

 Frame (framename)

Class for generating Stata select_var for getAsDict


source

StataMagics.magic_frbrowse

 StataMagics.magic_frbrowse (code, kernel, cell)

Display frame interactively.

https://github.com/bloomberg/ipydatagrid

Head/tail magics

Modeled after pandas.


source

StataMagics.magic_head

 StataMagics.magic_head (code, kernel, cell)

Display data in a nicely-formatted table.


source

StataMagics.magic_frhead

 StataMagics.magic_frhead (code, kernel, cell)

Display data in a nicely-formatted table.


source

StataMagics.magic_tail

 StataMagics.magic_tail (code, kernel, cell)

Display data in a nicely-formatted table.


source

StataMagics.magic_frtail

 StataMagics.magic_frtail (code, kernel, cell)

Display data in a nicely-formatted table.

Help magic


source

StataMagics.magic_help

 StataMagics.magic_help (code, kernel, cell)

Show help file from stata.com/help.cgi?{}

from IPython.core.display import HTML
test_instance = StataMagics()
out = test_instance._get_help_html("order")
HTML(out)
Stata 18 help for order

[D] order -- Reorder variables in dataset
Syntax
        order varlist [, options]
    options           Description
    -------------------------------------------------------------------------
    first             move varlist to beginning of dataset; the default
    last              move varlist to end of dataset
    before(varname)   move varlist before varname
    after(varname)    move varlist after varname
    alphabetic        alphabetize varlist and move it to beginning of dataset
    sequential        alphabetize varlist keeping numbers sequential and move
                        it to beginning of dataset
    -------------------------------------------------------------------------
Menu
    Data > Data utilities > Change order of variables
Description
    order relocates varlist to a position depending on which option you
    specify.  If no option is specified, order relocates varlist to the
    beginning of the dataset in the order in which the variables are
    specified.
Options
    first shifts varlist to the beginning of the dataset.  This is the
        default.
    last shifts varlist to the end of the dataset.
    before(varname) shifts varlist before varname.
    after(varname) shifts varlist after varname.
    alphabetic alphabetizes varlist and moves it to the beginning of the
        dataset.  For example, here is a varlist in alphabetic order:  a x7
        x70 x8 x80 z.  If combined with another option, alphabetic just
        alphabetizes varlist, and the movement of varlist is controlled by
        the other option.
    sequential alphabetizes varlist, keeping variables with the same ordered
        letters but with differing appended numbers in sequential order.
        varlist is moved to the beginning of the dataset.  For example, here
        is a varlist in sequential order: a x7 x8 x70 x80 z.
Examples
    Setup
        . webuse auto4
    Describe the dataset
        . describe
    Move make and mpg to the beginning of the dataset
        . order make mpg
    Describe the dataset
        . describe
    Make length be the last variable in the dataset
        . order length, last
    Describe the dataset
        . describe
    Make weight be the third variable in the dataset
        . order weight, before(price)
    Describe the dataset
        . describe
    Alphabetize the variables
        . order _all, alphabetic
    Describe the dataset
        . describe