• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / SAS / SAS yymmdd10. Date Format

SAS yymmdd10. Date Format

September 14, 2022 Leave a Comment

To format a date with the yymmdd10 format in SAS, you can format a date variable like ‘YYYY-MM-DD’.

data example;
    d = "14sep2022"d;
    put d yymmdd10.;
run;

// Log Output:
2022-09-14

If you want to format a date like ‘YYYY/MM/DD” then you can use yymmdds10 in a data step.

data example;
    d = "14sep2022"d;
    put d yymmdd10s.;
run;

// Log Output:
2022/09/14

When working with different variables in SAS, the ability to change formats easily is valuable.

One such case is if you have a date and want to format it differently.

A date format which is commonly used in real world applications is “YYYY-MM-DD”. This date format shows the full year, the month number and date separated by hyphens.

The SAS date format to get this date format is yymmdd10.

Below shows a simple example of formatting a date with yymmdd10. in a SAS data step.

data example;
    d = "14sep2022"d;
    put d yymmdd10.;
run;

// Log Output:
2022-09-14

If you want to format a date like ‘YYYY/MM/DD” then you can use yymmdds10. in a Data Step.

data example;
    d = "14sep2022"d;
    put d yymmdd10s.;
run;

// Log Output:
2022/09/14

Other Date Formats in SAS

There are a number of other date formats you can use in SAS to format date variables.

Below show you a bunch of different date formats and the resulting output in a SAS data step.

data example;
   d = "14sep2022"d;
   put d yymmdd2.;
   put d yymmdd3.;
   put d yymmdd4.;
   put d yymmdd5.;
   put d yymmdd6.;
   put d yymmdd7.;
   put d yymmdd8.;
   put d yymmdd10.;
   put d yyq.;
   put d yyq4.;
   put d yyq5.;
   put d yyq6.;
   put d yyq10.;
run;

// Log Output:
 22
  22
 2209
 22-09
 220914
  220914
 22-09-14
 2022-09-14
 2022Q3
 22Q3
  22Q3
 2022Q3
     2022Q3

Hopefully this article has been useful for you to learn how to use the SAS YYMMDD10 date format for formatting dates in SAS data steps.

Other Articles You'll Also Like:

  • 1.  SAS ceil – Round Up to Ceiling of Number in a SAS Data Step
  • 2.  SAS nodupkey – How to Remove Duplicates with PROC SORT by Key
  • 3.  SAS Remove Formats from Dataset with PROC DATASETS
  • 4.  IN in SAS – Checking if Variable is in Array of Values
  • 5.  =">SAS Greater Than or Equal to with GE or >=
  • 6.  SAS intnx – Add or Subtract Time from Date Variables in SAS Data Step
  • 7.  SAS Percent Format – Formatting Number as Percent in SAS Dataset
  • 8.  Concatenating Strings in a SAS Data Step
  • 9.  SAS tranwrd() Function – Replace Characters in Strings in SAS Data Step
  • 10.  SAS case when – Conditional Logic with case Expression in PROC SQL

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy