logo_learn_stats

Methods to Utility the MDY Serve as in SAS (With Examples)

Posted on
banner 336x280

You’ll be able to importance the MDY serve as in SAS to go back a hour worth from generation, year and occasion values.

This serve as makes use of please see syntax:

banner 468x60

MDY(generation, year, occasion)

the place:

  • generation: Integer worth for generation from 1 to twelve
  • year: Integer worth for year of the generation from 1 to 31
  • occasion: A two-digit or four-digit integer that represents the occasion

Refer to instance displays how one can importance the MDY serve as in observe.

Instance: Methods to Utility the MDY Serve as in SAS

Assume now we have please see dataset in SAS that comprises details about gross sales made on diverse dates at some retail pack:

/*form dataset*/
knowledge my_data;
    enter generation year occasion gross sales;
    datalines;
4 15 2022 94
6 17 2022 88
7 25 2022 90
8 14 2022 105
10 13 2022 119
12 15 2022 100
1 4 2023 87
3 15 2023 90
5 29 2023 130
;
run;

/*view dataset*/
proc print knowledge=my_data;

Refer to code displays how one can importance the MDY serve as to form dates the usage of the numeric values within the generation, year and occasion columns:

/*form unutilized dataset*/
knowledge new_data;
    eager my_data;
    date_numeric = mdy(generation, year, occasion);
    date_worddate = put(mdy(generation, year, occasion), worddate.);
    date_date9 = put(mdy(generation, year, occasion), date9.);
    date_mmddyy10 = put(mdy(generation, year, occasion), mmddyy10.);
run;

/*view dataset*/
proc print knowledge=new_data;

MDY function in SAS example

Realize that we impaired the MDY serve as to form 4 unutilized columns that every one comprise dates in diverse codecs.

Be aware #1: You’ll be able to discover a whole record of doable hour codecs in SAS right here.

Be aware #2: You’ll be able to to find the entire documentation for the SAS MDY serve as right here.

Backup Sources

Refer to tutorials give an explanation for how one can carry out alternative familiar duties in SAS:

Methods to Utility DAY, MONTH, and YEAR Purposes in SAS
Methods to Get Year of Occasion from Moment in SAS
Methods to Upload Days to Moment in SAS

banner 336x280

Leave a Reply

Your email address will not be published. Required fields are marked *