IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query in SAS to format the DATE field


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
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
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
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 All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts To Unstring spaces in a field COBOL Programming 3
No new posts Sort card to know that creation date ... DFSORT/ICETOOL 10
Search our Forums:


Back to Top