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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

9 REPLIES 9
art297
Opal | Level 21

I would submit a ticket to SAS tech support!

Patrick
Opal | Level 21

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?

Ksharp
Super User

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

cliff
Calcite | Level 5

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

art297
Opal | Level 21

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);


cliff
Calcite | Level 5

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!

art297
Opal | Level 21

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;

cliff
Calcite | Level 5

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?

Patrick
Opal | Level 21

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).

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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