DATA Step, Macro, Functions and more

Date length question and footnote question

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Date length question and footnote question

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;


Accepted Solutions
Solution
‎03-05-2017 07:52 PM
Super User
Posts: 19,770

Re: Date length question and footnote question

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


All Replies
Super User
Posts: 19,770

Re: Date length question and footnote question

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. 
Contributor
Posts: 27

Re: Date length question and footnote question

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?

Solution
‎03-05-2017 07:52 PM
Super User
Posts: 19,770

Re: Date length question and footnote question

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

 

Contributor
Posts: 27

Re: Date length question and footnote question

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?

Super User
Posts: 19,770

Re: Date length question and footnote question

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

Theres no second date. 

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 183 views
  • 0 likes
  • 2 in conversation