SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Create a date

Senior User
Posts: 1

Create a date

[ Edited ]

Hello SAS users

I have the attached kind of data:


I want to create a new variable, "date" which is a combination of the year and the number corresponding to the month (like this, 200810 to represent  Oct 2010)

please assist me.

Super User
Posts: 9,886

Re: Create a date

See my footnotes for how to post data. Excel files are mostly useless for this (unless your problem lies in importing them).

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,406

Re: Create a date

A date variable always has the three components = day, month, year.  If you do not have one then you need to default one in.  You can use ISO dates, which are character:


For a numeric, you can have a default, then format it to display differently:

format want monyy7.;
Super User
Posts: 10,686

Re: Create a date

If your variable is date type ,just add a format.

format your-variable  yymmn6.;

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation