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
 

 

Write Timestamp into output file. - SAS

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

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Sun May 20, 2012 5:34 pm    Post subject: Write Timestamp into output file. - SAS
Reply with quote

Hi,
I have a timstamp value inside a SAS dataset variable.
I would like to write it to an external PS file using PUT statement in the original format.

Code:
data timestamp;
infile 'dcollect.file';
input @13 timestmp SMFSTAMP8. ;
run;

<some processing comes here.>

data _null_;
set timestamp;
file 'some external file';
put @13 timestmp ??????; <- what format should i specify?
run;


Please let me know how we write the timestamp variable to external file in the same format in which it was read in the 1st step.

Thanks in advance,
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sun May 20, 2012 10:17 pm    Post subject:
Reply with quote

Did you try SMFSTAMP8. ?
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Sun May 20, 2012 10:22 pm    Post subject:
Reply with quote

Yes, It gave the error,
Code:

ERROR 48-59: The format SMFSTAMP was not found or could not be loaded.


I think SMFSTAMP is one of those things like $CHAR which are only informats used in INPUT statement but cannot be used in PUT statement.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Sun May 20, 2012 10:34 pm    Post subject:
Reply with quote

Yeah, looking at the SAS documentation, SMFSTAMP is an INFORMAT -- which means it cannot be used for output. But you might be able to use PD8. to put the value back out.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon May 21, 2012 12:27 pm    Post subject:
Reply with quote

Hi Robert,
Thanks for the suggestion.
I tried the PD and PIB formats, but it looks like timestamp read via SMFSTAMP8. is something different.
Code:

OPTIONS OBS = 10;   
DATA READSTAMP;             
 INFILE 'dcollect file';
 INPUT @13 TIMESTMP SMFSTAMP8.;   
 FILE 'WELLS.SORTIN';   
 PUT @13 TIMESTMP PIB8. @25 TIMESTMP PD8.;
RUN;   
       
DATA VERIFY;       
 INFILE 'WELLS.SORTIN';         
 INPUT @13 TIMSTMP1 SMFSTAMP8. @25 TIMSTMP2 SMFSTAMP8.;   
 PUT TIMSTMP1 DATETIME19. TIMSTMP2 DATETIME19.;       
RUN;   

Error:
NOTE: Invalid data for TIMSTMP1 in line 1 13-20. 
NOTE: Invalid data for TIMSTMP2 in line 1 25-32. 


I will try to search and see what format the data is originally stored in raw file.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon May 21, 2012 2:36 pm    Post subject:
Reply with quote

Thinking about it, I suspect SAS converts an SMFSTAMP value into a date/time value, which would be useless to output -- and difficult to translate. When I get a chance later on today, I'll see if I can come up with something reasonably straightforward to handle it.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon May 21, 2012 4:39 pm    Post subject:
Reply with quote

Quote:
I suspect SAS converts an SMFSTAMP value into a date/time value, which would be useless to output

Yes correct, it makes no sense to write sas datetime values in PD or IB formats. My bad, It did not occur to me.
Quote:
I'll see if I can come up with something reasonably straightforward to handle it.

I too will continue to search for a solution. Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon May 21, 2012 5:38 pm    Post subject:
Reply with quote

Suspicion confirmed. You can use something like this against an SMFSTAMP8 variable DTTM:
Code:
     CENT     = INT((YEAR(DATEPART(DTTM)) - 1900) / 100) ;
     YRVAL    = JULDATE(DATEPART(DTTM)) ;
     OUTVAL   = CENT * 100000 + YRVAL ;
     TM       = TIMEPART(DTTM) * 100  ;
     FORMAT TM IB4. OUTVAL PD4. ;
and output TM and OUTVAL which together will be the SMFSTAMP8. value.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon May 21, 2012 5:43 pm    Post subject:
Reply with quote

Works GREAT.!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Mon May 21, 2012 6:03 pm    Post subject:
Reply with quote

Good to hear that.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon May 21, 2012 10:10 pm    Post subject:
Reply with quote

Condensed ur code a little bit,
Code:
TM = TIMEPART(DTTM) * 100;             
OUTVAL = JULDATE(DATEPART(DTTM)) - 1900000;
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue May 22, 2012 2:16 am    Post subject:
Reply with quote

Yeah, the code I posted is designed to show what's happening, not be the most condensed. You don't want to have to make a change in 4 years and look at that code saying "Why 1900000?"
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Tue May 22, 2012 2:56 pm    Post subject:
Reply with quote

Robert, I understood that you were explaining things in detail, when you posted your code.
Quote:
make a change in 4 years and look at that code saying "Why 1900000?"

4 years? nah.. my retention period is 3-4 months.
I can't concentrate on a thing for more than 2... oh look, a cookie
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed May 30, 2012 12:30 pm    Post subject:
Reply with quote

I guess the next code (without any additional processing) would work :


Code:

data timestamp;
infile 'dcollect.file';
input @13 timestmp $CHAR8.;  /* <---------------- */
run;

<some processing comes here.>

data _null_;
set timestamp;
file 'some external file';
put @13 timestmp $8.;  /*------------------- */
run;
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed May 30, 2012 1:16 pm    Post subject:
Reply with quote

Hi Peter,
Thanks for your thoughts.
But in my case, the limitation is I will not be able to change the way the timestamp is read in the first step. It is read using SMFSTAMP. informat internally.

The below step was for describing the problem.
Code:
data timestamp;
infile 'dcollect.file';
input @13 timestmp SMFSTAMP8. ;
run;

Robert's technique helped in my case.
Thanks,
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed May 30, 2012 2:33 pm    Post subject:
Reply with quote

Vasanth, thought it was a 1 to 1 copy of the field.
With respect to Robert's solution my approach was to do it with with
a minimum of coding.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Wed May 30, 2012 2:41 pm    Post subject:
Reply with quote

Quote:
With respect to Robert's solution my approach was to do it with with
a minimum of coding.

Yup, Got your point.
Having alternate ways of doing the same thing are handy at times. May not be applicable in one scenario, but will be more suited and efficient in other scenarios.
Thanks,
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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