BookmarkSubscribeRSS Feed
ynchen08
Fluorite | Level 6

Hi all,

 

I have an excel worksheet (xlsx) where all fields were formatted as "General". When I first imported it into SAS, I realized that the variable, "Result", that has numerical values for some obervations and character values for other observations was imported as solely numerical variable (i.e., for those observations that have character values in the result field, the values become missing).

 

So I tried to use the following code to specify that I want the result field to be imported as character field. However, it does not seem like my code is working. Would y'all please let me know how to fix this issue?

 

proc import datafile="Z:\Positive Health Check\Data\1985-2017May Data\test2.xlsx" out=ts

DBMS=EXCEL replace;

DBDSOPTS= "DBTYPE=(RESULT='CHAR(20)')";

run;

 

1 REPLY 1
ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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