- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I'm trying to return the Date field in lower case, but only the day and month - so in the below example I'd like to see 01 Jan, 02 Jan etc..
data Test; input Day Vol; datalines; 20200101 685.47 20200102 734.91 20200103 726.01 20200104 767.21 20200104 891.71 ; run; PROC SQL; CREATE TABLE TEST1 AS SELECT Input( Put( Day, 8.), yymmdd8.) FORMAT=DATE5. AS Day, Vol FROM TEST; QUIT;
I've tried all the options with WORDDATX, WORDDATE but I can't find the way to only show day and month.
(of course LOWCASE is not an option as it's not a Char)
thanks in advance
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One way to get something like this:
PROC SQL; CREATE TABLE TEST1 AS SELECT lowcase(substr(put(Input( Put( Day, 8.), yymmdd8.),date9.),1,5)), Vol FROM TEST; QUIT;
You can create a custom format that would show just day of month and the month name. However the result will still have the month either upper case or proper case such as "Jan" . The result you showed is not actually lower case. Did you mean Proper case with the initial letter capital? And do you actually need a space between the day and the month?
proc format; picture dm low-high ='%0d %3B' (datatype=date) ; run; PROC SQL; CREATE TABLE TEST1 AS SELECT Input( Put( Day, 8.), yymmdd8.) as day format= dm., Vol FROM TEST; QUIT;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
One way to get something like this:
PROC SQL; CREATE TABLE TEST1 AS SELECT lowcase(substr(put(Input( Put( Day, 8.), yymmdd8.),date9.),1,5)), Vol FROM TEST; QUIT;
You can create a custom format that would show just day of month and the month name. However the result will still have the month either upper case or proper case such as "Jan" . The result you showed is not actually lower case. Did you mean Proper case with the initial letter capital? And do you actually need a space between the day and the month?
proc format; picture dm low-high ='%0d %3B' (datatype=date) ; run; PROC SQL; CREATE TABLE TEST1 AS SELECT Input( Put( Day, 8.), yymmdd8.) as day format= dm., Vol FROM TEST; QUIT;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ballardw
Thank you so much, this is exactly what I needed! - and you are right, I didn't explain it really well.
ps: I've very little knowledge of proc format; could you explain what '%0d %3B' mean?
(I'm pushing my luck here, but is there any chance it can be displayed as ,i.e. 1st Jan, 2nd Jan... ?)
once again thank you very much
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@MART1 wrote:
Hi @ballardw
Thank you so much, this is exactly what I needed! - and you are right, I didn't explain it really well.
ps: I've very little knowledge of proc format; could you explain what '%0d %3B' mean?
(I'm pushing my luck here, but is there any chance it can be displayed as ,i.e. 1st Jan, 2nd Jan... ?)
once again thank you very much
The PICTURE statement for Proc format has directives to build custom date, time or datetime formats. Read the documentation and is pretty clear. The % starts the directive, the 0 says to preface single digits with a zero, the lower case d is days (these directives are very case sensitive) a space before the next directive, the 3 says how many letters of the proper case month name indicated by B.
Please be aware this is one of the few places that you pretty much must use single quotes. If you use double quotes around these directives SAS will complain about macro issues because of the % characters.