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
 

 

Counting Records and formatting the total in SAS

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

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 4:46 pm    Post subject: Counting Records and formatting the total in SAS
Reply with quote

hi,

I need to count total number of records from an input file in to one o/p file using SAS. The O/P file should display the number of records in the fromat of 99,99,999. Iam using COUNT+1 to count the records. Please let me know how can i get a report with data 99,99,999. when i was using fomat count COMMA. -
FORMAT COUNT COMMA.
FILE SASREPT;
PUT @4 'TOTAL RECORDS: ' COUNT;
it is showing a value of 1.61E6(which is not in the from of 99,99,999) in the SASlog instead of in the O/p file.

thanks,
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 08, 2008 5:10 pm    Post subject:
Reply with quote

FORMAT COUNT COMMA.
will default to the length of 8, so not surprising you get exponential output.

Set the output length to something more reasonable for a large record count.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 5:16 pm    Post subject: Reply to: Counting Records and formatting the total in SAS
Reply with quote

in future the number of records may be large ....at this time i cant format it to comma20 rite...its based on the number of records....
i hv also mentioned that the count is not written in to the SAS file........
please provide is there is any better approach..........for these

i dont know much about SAS,,,,but iam trying to get something for this....
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 08, 2008 6:18 pm    Post subject:
Reply with quote

Quote:
at this time i cant format it to comma20


I usually use either COMMA19. or COMMA32.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 6:21 pm    Post subject:
Reply with quote

THANK YOU VERY MUCH.............
BUT WHERE CAN I USE THIS FORMAT....
WHEN I UESD BEFORE WRITING INTO THE O/P FILE......THE TOTAL REPORT WAS GENERATED IN SAS LOG..AND THE O/P FILE WAS EMPTY.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 08, 2008 6:33 pm    Post subject:
Reply with quote

Take a look at the code that I have used. This only reads a record and increments the counter until EOF.

The FILE statement points to the DDNAME where the output will be written to.
Code:

DATA _NULL_;                   
  FORMAT   COUNT    COMMA32.;   
  INFILE   DATEFILE EOF=EOF1;   
  INPUT    @01  DATEIN    PD4.;
  COUNT + 1;                   
  RETURN;                       
 EOF1:                         
  FILE TESTOUT;                 
  PUT @01 'COUNT WAS   ' COUNT;
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 08, 2008 6:39 pm    Post subject:
Reply with quote

The file that you want to count the records from ......... is it a flat file or a SAS file ?
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Fri Aug 08, 2008 7:06 pm    Post subject: Reply to: Counting Records and formatting the total in SAS
Reply with quote

Its a VSAM file.....
Iam able to get the o/p file now.......thanks for all ur help....

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 08, 2008 7:13 pm    Post subject:
Reply with quote

Please post your code for the benfit of others, because I know that VSAM files can be a bit of a pain in SAS.

But ................... IDCAMS LISTCAT would give you the record count, and does not have to read through the file.

When the file gets closed the record count is updated in the catalog, and LISTCAT will get the number of records in the file.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Aug 09, 2008 1:01 am    Post subject: Reply to: Counting Records and formatting the total in SAS
Reply with quote

Quote:
I know that VSAM files can be a bit of a pain in SAS

Not only is VSAM a 4-letter word, but now it is a pain in the SAS. . . icon_cool.gif

Happy Weekend icon_biggrin.gif

d
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Aug 09, 2008 5:35 am    Post subject:
Reply with quote

Quote:
Not only is VSAM a 4-letter word, but now it is a pain in the SAS
groan ... Dick, how could you?

I've never had any problems with VSAM files in SAS; reading them sequentially requires only one difference from a sequential file (the VSAM keyword on the INFILE statement). Reading them randomly isn't as easy in SAS as COBOL but it doesn't require a rocket scientist either.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Aug 09, 2008 9:05 am    Post subject: Reply to: Counting Records and formatting the total in SAS
Reply with quote

Quote:
groan ... Dick, how could you?
Devil made me. . . Thought i'd see who i could punish. . . icon_wink.gif

Oh, yeah, today is 888, not 666. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Aug 09, 2008 8:55 pm    Post subject:
Reply with quote

Quote:
Oh, yeah, today is 888, not 666. . .
meaning what? You're one-third MORE evil?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Sat Aug 09, 2008 9:18 pm    Post subject:
Reply with quote

Dick, surely tou meant COMMA888.
Back to top
View user's profile Send private message
s2nd2

New User


Joined: 08 Aug 2008
Posts: 6
Location: hyd

PostPosted: Mon Aug 11, 2008 10:38 am    Post subject: Reply to: Counting Records and formatting the total in SAS
Reply with quote

Quote:
Please post your code for the benfit of others, because I know that VSAM files can be a bit of a pain in SAS.


hi,

Iam using a VSAM file, but while reading iam not using any key.......but iam able to get the o/p with the count equal to i/p records in the input file.....
Let me know if iam doing aything wrong......

DATA MASTER_1
INFILE MASTER EOF=TOTALS;
INPUT @42 DATAT PD4.;
COUNT+1;
here my inout file is MASTER;

Thank You,
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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