Announcement

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

  • SAS Transport file: Time not formatting correctly

    I have a stata dataset containing times generated with this code:

    Code:
    generate strt_tmf = clock(strt_tm, "hm")
    format strt_tmf %tcHH:MM
    I am using [export sasxport] to convert the Stata files to SAS transport files but when I convert the SAS transport files to SAS datasets and view the data in SAS the time formats do not appear correct.

    Here's a screenshot of how I see the data in SAS. Does any anybody know if/how I can format the time so that it is recognised and formats correctly going from Stata -> SAS XPORT -> SAS dataset?

    STRT_TM is just an unformatted character variable.
    STRT_TMF is where I'm expecting to see a nicely formatted time

    Click image for larger version

Name:	Screen Shot 2017-02-17 at 10.28.45 am.png
Views:	1
Size:	106.7 KB
ID:	1374634



  • #2
    Maybe there is no time format that is completely compatible with Stata and SAS since a Stata time will always be /1000 of a SAS time?

    Click image for larger version

Name:	Screen Shot 2017-02-17 at 10.54.05 am.png
Views:	1
Size:	30.9 KB
ID:	1374636

    Comment


    • #3
      First, formatting information is not incorporated into the SAS transport file. It is placed into a separate formats file or a separate SAS code file, depending on what you specify in the -vallabfile()- option of your -export sasxport- command. When you read the SAS file in SAS you need to use that ancillary file (whichever you have) as well. But, this may be of to no avail anyway. As far as I know, the SASXPORT format does not support a format that looks like %tcHH:MM in any case.

      You might be better served by going directly from Stata to SAS, bypassing the SASXPORT version, using the Stat Transfer program. If you do this sort of thing with any frequency, Stat Transfer is well worth the investment--it is not expensive and it works really well, giving you the ability to transfer files among all common database, spreadsheet, and statistical packages. If this is something you only seldom need to do, perhaps you can find somebody in your locale who has it and will make the transfer for you.

      Comment


      • #4
        Thanks Clyde. I just used my trial version of Stat Transfer and times are perfectly formatted in the resulting SAS files. Looks like I'll have to pull out my wallet

        Comment


        • #5
          I thought that SAS formats (BEST8., DATE9., HHMM. etc.), as opposed to user-defined formats, can be stored in the dataset file, itself, and optionally in a separate SAS program (PROC FORMAT) file.

          Comment

          Working...
          X