- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data l;
input id$ 1-12;
id1=input(id,date9.);
id2=input(id,date9.);
format id1 date.;
format id2 date9.;
cards;
15-sep-10
run;
proc print;
run;
i want the out put in dd-mon-yy format what is the format i sould use to get the output like this.
id1
15-sep-10
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The easiest way to accomplish this is to build your own picture format using directives:
%0d - gives you the day of the month, with a leading zero if a single digit
%b - gives you the month abbreviation
%0y - gives you the 2 digit year with a leading zero if a single digit. For a 4 digit year you can use the date11. format.
proc format ;
picture date9d other = '%0d-%b-%0y'( datatype= date ) ;
run;
format id1 date9d.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The closest format I could find was ddmmyyd10. It outputs date in form 15-09-10. Maybe it helps.
Ieva
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
if you can live with a 4 digit year, you can use date11. Otherwise, you may have to roll your own using proc format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As Art suggests, the closest is DATE11. followed by writing your own with something like
proc format ;
picture date9x other = '%0d-%b-%0y'( datatype= date ) ;
picture date9t other = '%0d-%b-%0y'( datatype= datetime ) ;
run ;
* testing ;
%put %sysfunc( today(), date9x ) ;
%put from datetime value, %sysfunc( datetime(), date9t ) ;
which report to the log like
5 %put %sysfunc( today(), date9x ) ;
28-NOV-11
6 %put from datetime value, %sysfunc( datetime(), date9t ) ;
from datetime value, 28-NOV-11
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%LET date=%SYSFUNC( PUTN( %SYSFUNC( DATE() ),date11. ));
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you *really* want to have the three-letter month name lower-cased, then here is one way. hth.
/* create a custom date format, datedash,
for the date range, 1jan2010 - 31dec2030 */
data f;
retain fmtname "datedash";
drop d;
do d = '1jan2010'd to '31dec2030'd;
start = d;
label = catx('-', put(day(d), z2.0),
lowcase(put(d, monname3.)),
put(d, year2.));
output;
end;
hlo = "other";
label = repeat("*",9-1);
output;
run;
proc format cntlin=f;
run;
/* check */
data _null_;
do d = '31dec2009'd, '1sep2010'd,
'15dec2015'd, '31dec2030'd, '1jan2031'd;
put d= :datedash.;
end;
run;
/* on log
d=*********
d=01-sep-10
d=15-dec-15
d=31-dec-30
d=*********
*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The easiest way to accomplish this is to build your own picture format using directives:
%0d - gives you the day of the month, with a leading zero if a single digit
%b - gives you the month abbreviation
%0y - gives you the 2 digit year with a leading zero if a single digit. For a 4 digit year you can use the date11. format.
proc format ;
picture date9d other = '%0d-%b-%0y'( datatype= date ) ;
run;
format id1 date9d.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_; | ||
monyy = &runasofdate; | ||
date1 =input(put(monyy,10.),yymmdd10.); | ||
put date1=date11.; | ||
call symput('date1',STRIP(date1)); | ||
run; | ||
%PUT &date1; |
Data _null_; | |||
a = &date1; | |||
dt1 =put (a, date11.); | |||
put dt1; | |||
run_date=((substr(strip(dt1),1,7)))||(substr(strip(dt1),10,2)); | |||
call symput('run_date',STRIP(run_date)); | |||
run; %PUT &run_date; | |||
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data _null_; | ||
monyy = &runasofdate; | ||
date1 =input(put(monyy,10.),yymmdd10.); | ||
put date1=date11.; | ||
call symput('date1',STRIP(date1)); | ||
run; | ||
%PUT &date1; |
Data _null_; | |||
a = &date1; | |||
dt1 =put (a, date11.); | |||
put dt1; | |||
run_date=((substr(strip(dt1),1,7)))||(substr(strip(dt1),10,2)); | |||
call symput('run_date',STRIP(run_date)); | |||
run; | |||
%let run_date1="'&run_date'd"; | |||
%let run_date = %sysfunc( dequote(&run_date1)) ; | |||
%PUT &run_date; |