Announcement

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

  • Errors with value labels when importing SAS file

    Hello,

    I have a SAS dataset of PRAMS data that I want to analyze in Stata. I do not have SAS on my computer. I successfully converted the SAS data to a Stata file using the code "import sas using "filename.sas7bdat", bcat("formats.sas7bcat") where the first file is the data file and the second file (formats) is the value labels file. However, I am getting errors with the value labels. For every variable it says "note:invalid string value C for value label CPNU, skipped" or "note:invalid numeric value for value label DRINKF, skipped" or "no values defined for value label STRAT2KS,removed" etc. Does anyone have advice on how to fix this? I am baffled.

    Thank you,

    Sarah

  • #2
    Originally posted by Sarah Haynes View Post
    For every variable it says "note:invalid string value C for value label CPNU, skipped" or "note:invalid numeric value for value label DRINKF, skipped" or "no values defined for value label STRAT2KS,removed" etc. Does anyone have advice on how to fix this?
    Every variable?

    I've never encountered an invalid numeric value for a SAS format, but I supposed that if it's possible, a noninteger or something.

    If you can rule out that the catalogue file is not corrupted, then you could either see whether the source has the datasets in some other format that is decoded (preferable) or if the source has a data dictionary in a format from which you can copy the text to paste into a DO-file, incorporating the contents into label define commands (tedious).

    Comment


    • #3
      Oh, a third option that I've seen is if the source has the formats in a separate SAS program. That's relatively easily modified with a text editor to reconfigure it to the corresponding label define commands. The DO-file can flag string variables in the dataset (detecting a string value format SAS statement), encode them and then swap in the numeric value labels created from the string value format.

      Comment

      Working...
      X