Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query in SAS to format the DATE field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
sindhuvava
Currently Banned

New User


Joined: 05 Dec 2006
Posts: 17
Location: Chennai

PostPosted: Wed Dec 06, 2006 4:19 pm    Post subject: Query in SAS to format the DATE field
Reply with quote

can anyone help me in doin this.
In the table i have a field OCCUPANCY_DT and the date is in the format
2006-12-02.
But i want the query output for this in the format 20061202.
How to write the query in SAS.
i tried by the followin code but its not workin:
SELECT SUBSTR(C.OCCUPANCY_DT,1,4)||SUBSTR(C.OCCUPANCY_DT,6,2)||
SUBSTR(C.OCCUPANCY_DT,9,2) FROM TABLE NAME;
The query message i am getting is:
Argument '1' of scalar function 'SUBSTR' is invalid.
Back to top
View user's profile Send private message

Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Wed Dec 06, 2006 11:00 pm    Post subject:
Reply with quote

I'm assuming that OCCUPANCY_DT is a DATE column in a relational database like DB2 or ORACLE. If that is true, then the query will return the column as a SAS date variable and you can just assign it a format like:
format OCCUPANCY_DT yymmddn8.;
If you what it to be returned as a character string, then you need to "cast" it to char and then work from it there, or, within the SAS code, bring it back as a date and then do:
OCCUPANCY_DT1 = put(OCCUPANCY_DT,yymmddn8.);
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us