BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Denali
Quartz | Level 8

Hi, I imported the attached Excel file to SAS.

In Excel, the last 7 variables are "14, 15, 16, 17, 18, 19 and 20." with 3 categories "True, False and Not sure".

In SAS, they are labeled as "_40,  _50, _60 , _70, _8, _9 , _01". However, the 3 categories were transformed into 0, 1 and .

I noticed that 0 = False, 1 = True , . = Not sure and the real missing values.

 

How do I correct this import formatting issue? Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

SAS variable names by default start with either a letter or the _ character, the remaining characters of the variable name may be _, letters or digits. So since your file has improper variable names the first character is replaced by an _.

 

I suspect that you also have name issues because column K and L both have 1 as the header value and all of your headers start with a digit from column K onward. You might want to prefix them with a Q (question) or F (field) or similar to get acceptable names if the _ bothers you.

 

With out knows how you imported the file I can't say where the 1 and 0 come from exactly as I haven't seen that behavior before.

If that were my data I would

1) Save the file as CSV

2) write a data step to import the data

3) using custom informats so I can assign special missing values to the "not sure" if appropriate. Since fields 6 through 10 and 11 through 13 appear to have the same coding for those and the 14-20 the True/false that would only be three informats. I really don't like text values for such things as the sort orders usually don't make sense in any form and for Likert type scales you need to place the responses at least in order that is easier with a numeric value than "Somewhat likely" and "Somewhat unlikely".

In the data step use a more meaningful variable name then 14 or at least assign a Label to indicate more about the variable.

 

View solution in original post

1 REPLY 1
ballardw
Super User

SAS variable names by default start with either a letter or the _ character, the remaining characters of the variable name may be _, letters or digits. So since your file has improper variable names the first character is replaced by an _.

 

I suspect that you also have name issues because column K and L both have 1 as the header value and all of your headers start with a digit from column K onward. You might want to prefix them with a Q (question) or F (field) or similar to get acceptable names if the _ bothers you.

 

With out knows how you imported the file I can't say where the 1 and 0 come from exactly as I haven't seen that behavior before.

If that were my data I would

1) Save the file as CSV

2) write a data step to import the data

3) using custom informats so I can assign special missing values to the "not sure" if appropriate. Since fields 6 through 10 and 11 through 13 appear to have the same coding for those and the 14-20 the True/false that would only be three informats. I really don't like text values for such things as the sort orders usually don't make sense in any form and for Likert type scales you need to place the responses at least in order that is easier with a numeric value than "Somewhat likely" and "Somewhat unlikely".

In the data step use a more meaningful variable name then 14 or at least assign a Label to indicate more about the variable.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1582 views
  • 0 likes
  • 2 in conversation