SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Data format issue

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Data format issue

Hello, I have a data set and whenever I open it in the SAS explorer, the log shows ERROR: There was a problem with the format so BEST. was used.

I figure out it is due to the format of one variable - meetingdate.

The length is 8,

Type is numeric

Format is YYMMDDN8.

Informat is MMDDYY10.

so I try to change the format:

data issue02; set issue01;

         format meetingdate MMDDYY10.;

run;

but when I open the issue02, the same error still exists. and now for the meetingdate variable in data set issue2:

The length is 8,

Type is numeric

Format is MMDDYY10.

Informat is 10.

Another data set in my computer with a date variable of the same attributes does not have such error.

I google and try to use the code like:

data issue02; set issue01;

     informat   meetingdate    10.;

    format   meetingdate     best10.;

    length   meetingdate   8;

run;

Now there is no error, but some of the date variable become  17589.4167, which should be 20080227.

                                             some are 17224, some are correctly as 20120321.

When I drop the meetingdate variable in data set issue2, the error disappears.

My SAS is 9.4 TS Level 1M2, W32_7PRO platform.

My old computer has a 64-big operating system.

Any suggestions? Thanks.


Accepted Solutions
Solution
‎12-22-2014 05:55 PM
PROC Star
Posts: 7,363

Re: Data format issue

Does the following match and (hopefully) correct your data problem?:

data have;

  length meetingdate 8;

  format meetingdate best12.;

  informat meetingdate 12.;

  input meetingdate;

  cards;

17589.4167

17224

20120321

;

data want;

  set have;

  format meetingdate date9.;

  meetingdate=int(meetingdate);

  if meetingdate gt 10000000 then do;

    meetingdate=input(put(meetingdate,8.),yymmdd8.);

  end;

run;

View solution in original post


All Replies
PROC Star
Posts: 7,363

Re: Data format issue

I would submit a ticket to SAS tech support!

Respected Advisor
Posts: 3,893

Re: Data format issue

My SAS is 9.4 TS Level 1M2, W32_7PRO platform.

My old computer has a 64-big operating system.

Does this mean you're trying to manipulate a 64bit SAS data set with a 32bit SAS?

Super User
Posts: 9,681

Re: Data format issue

Try run the following code :

proc datasets library=work nolist;

modify have;

  attrib _all_ format= ;

quit;

Which remove all variables's formats . and after that add the variable's format as you will .

Good Luck.

Xia Keshan

Occasional Contributor
Posts: 9

Re: Data format issue

Thanks. I tried this one, but the error appears when I tried to transfer the numbers to date.

PROC Star
Posts: 7,363

Re: Data format issue

While they may be some 32-bit/64-bit incompatibilities I'm not aware of, one of your examples might be explained.

The integer portion of 17589.4167 does, in fact, represent the date 20080227. It could be that some of your values are datetimes with the time represented as a fraction.


How does your data appear if you take the integer portion of all of the dates? e.g.:


date=int(date);


Occasional Contributor
Posts: 9

Re: Data format issue

I try to get the integer portion, and then when I change it back to date format, the error appears again.

As I did before, I have some of the date variable become  17589.4167, some are 17224, some are correctly as 20120321.

So I use int(meetingdate) then this variable has only numbers like: 17224, 17589, and 20120321.

Then when I use "format meetingdate date9." the error appears again.

I figure the error is from the date like 20120321, when those dates are in the same column as the 17224 dates, I will have such error.

So I divide the dateset into two parts, data1 with dates like 20120321, data2 with dates like 17224.

Then when I change these numbers into dates, the separate date sets are error free.

But when I try to merge them, the error appears.

The attributes of dates in data1 are

length:8

Format BEST12.

informat: 12.

So if I can find a correct date format for the date variable in data2, I can merge these two datasets together and solve the problem. Any suggestions? Thanks!

Solution
‎12-22-2014 05:55 PM
PROC Star
Posts: 7,363

Re: Data format issue

Does the following match and (hopefully) correct your data problem?:

data have;

  length meetingdate 8;

  format meetingdate best12.;

  informat meetingdate 12.;

  input meetingdate;

  cards;

17589.4167

17224

20120321

;

data want;

  set have;

  format meetingdate date9.;

  meetingdate=int(meetingdate);

  if meetingdate gt 10000000 then do;

    meetingdate=input(put(meetingdate,8.),yymmdd8.);

  end;

run;

Occasional Contributor
Posts: 9

Re: Data format issue

Thanks! There is no error now!

Could I also ask why now the meetingdate with format as date9. can be stay with the meetingdate with format as yymmdd8.?

Or in the whole process, format meetingdate date9. actually only applies after the do loop, so yymmdd8. is dominated by date9. finally?

Respected Advisor
Posts: 3,893

Re: Data format issue

In Art's code date9. is the format so that is how a SAS Date value will be printed. yymmdd8. is an INformat so that is how SAS will read/interpret a text string when converting into a SAS Date value (number of days since 1/1/1960).

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 1771 views
  • 0 likes
  • 4 in conversation