Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set variable formats for STATA when specified #320

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

seidelma
Copy link

@seidelma seidelma commented Oct 28, 2024

When converting data from CSV with a JSON metadata file to STATA, the variable formats were being dropped. This caused STATA not to display the variables correctly, as described in #312, to wit:

. use "stata_repro"
((null))

. describe

Contains data from stata_repro.dta
 Observations:             2                  (null)
    Variables:             3                  24 Oct 2024 15:08
-----------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-----------------------------------------------------------------------
permno          double  %10.0g                CRSP permno (permno)
date            long    %12.0g                Day of last price observation (date)
eom             long    %12.0g                End of month (eom)
-----------------------------------------------------------------------

The date and eom fields should be of type "DATE" (and permno should be "UNSPECIFIED"), as specified in the .json file.

With this change, STATA now recognizes the data display format, eg:

. use "output"
((null))

. describe

Contains data from output.dta
 Observations:             2                  (null)
    Variables:             3                  28 Oct 2024 12:41
-----------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-----------------------------------------------------------------------
permno          double  %9.0f                 CRSP permno (permno)
date            long    %td                   Day of last price observation (date)
eom             long    %td                   End of month (eom)
-----------------------------------------------------------------------
Sorted by:

. list

     +--------------------------------+
     | permno        date         eom |
     |--------------------------------|
1. |  10107   31jan2020   31jan2020 |
2. |  10107   28feb2020   29feb2020 |
     +--------------------------------+

@FlipperPA
Copy link

Thank you @seidelma! This fixes #312. I've compiled and confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants