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

I hope all of you are having a good afternoon. After the code below is executed, why is the length of date1 equal to 8 rather than 9?

 

data test;

date=input("09MAR2013",date9.);

run;

 

For the footnote question, why does the following only create the footnotes "A" and "E"?

 

footnote1 "A";

footnote2 "B";

footnote3 "C";

footnote4 "D";

proc print data=data1;

footnote2 "E";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Let me flip that back to you:

Why should it have a length of 9? What did the INPUT function do in this case?

 

Run the example below and Note that the following prints the exact same dataset each time. No changes to the variable underlying value are made.

 

 

data test;
date=input("09DEC2013",date9.);
run;

title 'Example 1';
proc print data=test;
format date date9.;
run;

title 'Example 2';
proc print data=test;
format date mmddyy8.;
run;

title 'Example 3';
proc print data=test;
format date worddate.;
run;

Here's a reference to the documentation on how SAS stores date, times and datetimes.

 

SAS Date and Time

http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4l...

 

View solution in original post

5 REPLIES 5
Reeza
Super User

I think you're mixing things up somewhere.

 

For first question, there is no date variable called date1. There is a variable called date and the length is 8.

 

For second question, you don't have a dataset called test1 that you've shown us. 

 

When you create footnote2 it erases all the others below it, ie footnote2+ are set to blank.

 http://support.sas.com/documentation/cdl/en/grstatproc/69716/HTML/default/viewer.htm#n1ukd9sqgqiwwhn...

The most recently specified TITLE or FOOTNOTE statement of any number completely replaces any other TITLE or FOOTNOTE statement of that number. In addition, it cancels all TITLE or FOOTNOTE statements of a higher number. For example, if you define TITLE1, TITLE2, and TITLE3, then submitting a new TITLE2 statement cancels TITLE3. 
smw10
Fluorite | Level 6

Thank you for your response. I meant to say date rather than date1. Why does it have a length of 8 rather than a length of 9?

Reeza
Super User

Let me flip that back to you:

Why should it have a length of 9? What did the INPUT function do in this case?

 

Run the example below and Note that the following prints the exact same dataset each time. No changes to the variable underlying value are made.

 

 

data test;
date=input("09DEC2013",date9.);
run;

title 'Example 1';
proc print data=test;
format date date9.;
run;

title 'Example 2';
proc print data=test;
format date mmddyy8.;
run;

title 'Example 3';
proc print data=test;
format date worddate.;
run;

Here's a reference to the documentation on how SAS stores date, times and datetimes.

 

SAS Date and Time

http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4l...

 

smw10
Fluorite | Level 6

Thank you for the explanation and the article. Just to make sure I understand,  when we read a date value as numeric, it represents the number of days between January 1, 1960, and a specified date.  Even after formatting it as mmddyy8., date9., or any other date format for that matter, the underlying value is still the number of days between January 1, 1960, and a specified date. The only way to make that specific date have a length of 9 is to convert it to character with a format of date9. Is this correct?

Reeza
Super User

A Date is the number of days from Jan 1, 1960. 

Theres no second date. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 900 views
  • 0 likes
  • 2 in conversation