Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date format question

Status
Not open for further replies.

evaaseow

Programmer
Jan 25, 2007
29
CA
Hi I want to take a datetime field and reformt it so it looks like 'YYYYMM'.

Is this possible in SAS?
 
Here try this:
Code:
data _null_;
  x = datetime(); *** THIS IS THE DATETIME VALUE ***;
  y = datepart(x);*** THIS IS THE DATE PORTION   ***;
  put x= y=;
  format x worddate32. y yymmn6.;*** NOTICE THE FORMAT FOR YYYYMM ***;
run;

Now that you understand the theory here is the shorter version.
Code:
formated_date = put(datepart(datetime_value),yymmn6.);


Hope this helps you.
Klaz
 
I tried this but i'm getting format not found or could not be loaded.
 
What version of SAS are you using? I tried this on versions 6, 8 & 9 and it works with all of them. Perhaps, you can contact SAS tech support for why you can't access this format.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top