Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us