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
 

 

Processing stem with some 1000 entries.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
cigarman

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Thu Dec 04, 2008 7:49 am    Post subject: Processing stem with some 1000 entries.
Reply with quote

Hello folks.

I have problem to solve and would like your input please.

I have a stem with some 1000 entries. Each entry is only 8 bytes each. Its a list of applids from CL/Stupersession.

Anyway. What I want to do is create a target stem which has only unique applids and a second stem that has a count of the applid from the original.

like so.

Source stem
a.1 = TSO
a.2 = NDM
a.3 = TSO

Target stems
b.1 = TSO
b.2 = NDM

c.1 = 2 (two tsos in source stem)
c.2 = 1

any suggestions would be greatly appreciated.

thanks in advance
rp
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Dec 04, 2008 9:31 am    Post subject: Reply to: Processing stem.
Reply with quote

Cigar,

Quote:
I have a stem with some 1000 entries.


How was this stem populated? If it was populated by reading an input file then

- Invoke DFSORT from REXX to eliminate the duplicates and to get the count.

AFAIK coding logic in REXX is difficult for this requirement.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Thu Dec 04, 2008 9:33 am    Post subject: Reply to: Processing stem.
Reply with quote

use the facts that you can set a default stem's default value and that the tails of rexx stems do not need to be numbers. No comments in the code because figuring it out is a good exercise. For example, it uses stems to contain indices into other stems. If you use these techniques in code others will maintain, add GOOD comments though because at first glance, it is indecipherable.
Code:
/* make some test data  */

a.0 = 4000
do i = 1 to a.0
  if random(100) < 30 then
    a.i = 'TSO'
  else
    a.i = 'NDM'
end

cindex = 0

/* create the stems. b is unique values, c is counts  */

knownvalues. = "not set"
knownvaluecount = 0
c. = 0
b. = 0

do i = 1 to a.0
  val = a.i
  if knownvalues.val == "not set" then
    do
      knownvaluecount = knownvaluecount + 1
      knownvalues.val = knownvaluecount
      b.knownvaluecount = val
      b.0 = knownvaluecount
      cindex = knownvaluecount
    end
  else
    cindex = knownvalues.val
  c.cindex = c.cindex + 1
end
c.0 = knownvaluecount

/* print the results  */

do i=1 to b.0
  say "b." || i || "=" || b.i
end
do i=1 to c.0
  say "c." || i || "=" || c.i
end

do i = 1 to b.0
  count = c.i
  say "there are "c.i" instances of "b.i
end

example output
Code:
b.1=NDM
b.2=TSO
c.1=2831
c.2=1169
there are 2831 instances of NDM
there are 1169 instances of TSO
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Dec 04, 2008 9:53 am    Post subject: Reply to: Processing stem.
Reply with quote

Mbabu,

Thanks for the code. It would be great if you can explain us the logic in few words.
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: Thu Dec 04, 2008 10:09 am    Post subject:
Reply with quote

Hello,

Please read the words above the code. . .

Quote:
No comments in the code because figuring it out is a good exercise.
Part of the contribution was the opportunity for some to learn, not just grab and run icon_wink.gif
Back to top
View user's profile Send private message
cigarman

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Thu Dec 04, 2008 10:36 am    Post subject:
Reply with quote

Arau: Thanks for the comment. I will keep DFSORT in mind for future code.

Mbabu: This is really good stuff. I will dig into it tomorrow, but I think its exactly what I'm looking for. At a quick glance, it looks cool. I will have to go through it line by line to understand.

Thanks to both or you.

rp
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Thu Dec 04, 2008 11:16 am    Post subject: Reply to: Processing stem.
Reply with quote

a quick and dirt google with "rexx stem sort" gave..

http://www.markcrocker.com/rexxtipsntricks/rxtt28.2.0475.html
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Dec 04, 2008 3:28 pm    Post subject: Reply to: Processing stem with some 1000 entries.
Reply with quote

Dick,

Quote:
Part of the contribution was the opportunity for some to learn, not just grab and run


Had i just wanted to Grab and run i would not have asked for an explanation icon_biggrin.gif . I would have executed it as such.

Anyways as per your suggestion let me take a look at it.
Back to top
View user's profile Send private message
cigarman

New User


Joined: 19 May 2007
Posts: 25
Location: Chicago

PostPosted: Fri Dec 05, 2008 7:25 am    Post subject:
Reply with quote

Mbabu:

This is perfect. Does exactly what I need. I went through it line by line. Desktop debugging shows me where the vars are going, but I still really don't know how its working. What would be a the term for what is going on here so I may look it up.

Thanks

rp
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Sat Dec 06, 2008 7:58 am    Post subject: commented code
Reply with quote

Here are comments on the relevant lines. I moved one line out of the loop for efficiency and clarity.
Code:
cindex = 0

/* Create the stems. B is unique values, C is counts.               */
 
/* Known values will contain a running list of values read from stem
   a.  We will check to see if a value is known by using the value as
   a tail named v Knownvalues.Val will return the tail, Of the
   corresponding stems b and c.  If The string "Not set" Will be
   returned and a new slot (Tail) Will be allocated
                                                                    */
knownvalues. = "not set"
/* Known value count is the index or tail number for b and c used
   for the last new value  found in a.                              */
knownvaluecount = 0
/* B is the list of values and c the number of entries for that value*/
c. = 0
b. = 0
   /* Read stem values of a                                         */
Do i = 1 to a.0
  val = a.i          /* We'll use the value as a tail in other stems */
   /* See if the value is known already                             */
  If knownvalues.val == "not set" Then /* Value is not known        */
    Do
      /* Get a new index for stems b and c to hold info on value    */
      knownvaluecount = knownvaluecount + 1
      /* Save value as next entry in knownvalues                    */
      knownvalues.val = knownvaluecount
      /* Save actual value in stem b at next index                  */
      b.knownvaluecount = val
      /* Set cindex to new index value                              */
      cindex = knownvaluecount
    End
  Else                         /* Value is already known            */
    cindex = knownvalues.val
  /* Update the count using the existing tale for this value cindex */
  c.cindex = c.cindex + 1
End
   /* Since knownvalue count is the value of the last used stem,
      We can use it to set the zero tail of b and c for future
      reference                                                     */
b.0 = knownvaluecount
c.0 = knownvaluecount
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 Dec 06, 2008 8:17 am    Post subject: Reply to: Processing stem with some 1000 entries.
Reply with quote

Thank you icon_cool.gif

d
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Run stats processing on zIIP Engine Virendra Shambharkar DB2 9 Fri Oct 14, 2016 10:24 am
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm
No new posts Is it possible to pass variables of s... Csongor CLIST & REXX 2 Fri Jun 10, 2016 7:33 pm
No new posts Extracting Information from DD Statem... Charles Wolters All Other Mainframe Topics 7 Wed Apr 13, 2016 10:21 pm
No new posts Finding out consecutive date entries ... bhavya_sha DFSORT/ICETOOL 10 Fri Nov 20, 2015 3:24 pm


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