Help using Base SAS procedures

Date conversion and trim function

Reply
Frequent Contributor
Posts: 90

Date conversion and trim function

Hi,

I have the dataset with the fields, the eff and exp fields are the date type.

ID comp grp eff exp
1 04 y 09/10/2010 08/12/2013
2 07 h 09/03/2009 07/02/2017

I need the report to looks like,

ID comp grp eff exp
1 04 y 20101009 20131208}
2 07 h 20090309 20170207}

Thanks in advance.
Super Contributor
Posts: 578

Re: Date conversion and trim function

I think all you need to do is change the format of the date columns to yymmddn8. Do you need to add the "}" at the end of the second date?
Frequent Contributor
Posts: 90

Re: Date conversion and trim function

Hi DBailey,

Yes I need to } at the end of the field.
Super Contributor
Super Contributor
Posts: 3,174

Re: Date conversion and trim function

Use a DATA step approach and the PUT statement to generate the data-lines.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

data step put statement external file site:sas.com
SAS Employee
Posts: 105

Re: Date conversion and trim function

Hey,
You can use the proc format picture statment.
For Example:

data temp;
eff='09oct2010'd;
output;
eff='09mar2009'd;
output;
format eff ddmmyy10.;
run;

proc format;
picture date_t (default=11)
'01jan1950'd-'31dec2011'd='%0d%0m%Y}'
(datatype=date);
run;
data temp2;
set temp;
format eff date_t.;
run;
Ask a Question
Discussion stats
  • 4 replies
  • 113 views
  • 0 likes
  • 4 in conversation