Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS global date display format default

Tags:

sas

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:

  • How do I display data in YYYYMMDD format
  • Change date format and informat
  • Using Dates in Calculations
  • SAS change date format
like image 434
tipanverella Avatar asked Jan 25 '26 11:01

tipanverella


2 Answers

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.

like image 130
Tom Avatar answered Jan 29 '26 06:01

Tom


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;
like image 26
Wired604 Avatar answered Jan 29 '26 06:01

Wired604