2
votes

I know that I can change the display format of a date variable in SAS using something like the following:

data junk0;
    x = date();
    format x yymmddd10.;
run;

Could someone show me how to set the default display format for date variables to something other than the system default: date9.?

With your solution the following:

<your SAS magic here>
data junk1:
    x = date();
    y = date()-1;
run;

would format both x and y properly, just because they are date variables.

I have done some homework, but none of the following links (although great), help me figure this out:

2

2 Answers

5
votes

There is no system default display value. You get to decide for every variable what (if any) display format you want to attach to it.

SAS datasets have only two types of variables, fixed length characters and floating point numbers. DATE values are only considered dates by your decision to attach a date type format to it and use in functions like MONTH(), DAY(), INTNX(), etc that expect date values.

1
votes

you could add a macro and then call the macro over all date you would want into that format... it's not ideal but it would work.

%macro date_standard(date=);
    put(&date.,yymmdd10.);  
%mend;
data junk1;
    x = %date_standard(date=date());
    y = date()-1;
run;