DATA Step, Macro, Functions and more

character ad numeric data.

Reply
Super Contributor
Posts: 647

character ad numeric data.

I use proc import to create sas datasets from excel files.
One of the fields patient_id , the first two records are 0711F08* and the rest of the records are numbers. SAS leaves a blank for the first two records for the patient id.
Without manually changing the data, is there anyway to import all the records?
Valued Guide
Posts: 2,174

Re: character ad numeric data.

option
mixed=yes
should allow the entire column to be treated as text.

Have you considered using the excel libname engine?

PeterC
Super Contributor
Posts: 647

Re: character ad numeric data.

Peter,
Thanks for the help.When I use option mixed =yes, the date filed is giving me a funky output. The first two values in the data field as shown below are displayed as
39980 (instead of 06/16/2009)
39993 (instead of 06/29/2009)

The rest of the date values are displayed correctly!
Super User
Posts: 10,483

Re: character ad numeric data.

> Peter,
> Thanks for the help.When I use option mixed =yes,
> the date filed is giving me a funky output. The
> first two values in the data field as shown below
> are displayed as
> 39980 (instead of 06/16/2009)
> 39993 (instead of 06/29/2009)
>
> The rest of the date values are displayed correctly!

Apply a SAS date FORMAT to the variable, MMDDYY10. would work, to display as human useable date. Those values are the SAS day offset values it uses for numerical purposes. Notice that they differ by 13 matching the date difference.
PROC Star
Posts: 1,561

Re: character ad numeric data.

Note that 39980 is 17JUN2069, not 16JUN2009.

The reason would be that excel counts days from 1/1/1900, whereas sas counts them from 1/1/1960, so the excel value has 60 more years into it. Not sure how you got to read 39980 in the 1st place, or why there is still a day difference, but now that you know the rule, you should be able to corrrect the date using function intnx.
Ask a Question
Discussion stats
  • 4 replies
  • 129 views
  • 0 likes
  • 4 in conversation