BookmarkSubscribeRSS Feed
murali_vijayend
Calcite | Level 5

hi 

i can fetch data from ims data through infile stathement. 

 

but some time, segments contain multiple occurrences of data...how sas handle ims data multiple occurrence,

for example below situation

01 Automatic Teller Record

     02 ATM Information

           03 ATM Location (occurs 20 times)

                04 Location

                04 ATM Transaction Information (occurs 7 times)

 

pls share some sample code.

 

thanks...

10 REPLIES 10
Shmuel
Garnet | Level 18

your input record is probably a variable length and there should be a field containing

the number of occurences (probably binary, one or two bytes).

 

can you post a screenshot or text lines with, at least one record in HEX mode 

and post the record layout

 

 

murali_vijayend
Calcite | Level 5

Thanks , Am sorry unable to do screen shot, due to security issues.

 

Hi,

 

I am using Mainframe BASE SAS, I can see the COPY LIB.

 

I am using INFILE and input statement to read the data.

 

I am using code like below

 

  data distribc;
     length  $11;
     keep ziprange
           check_amount
            balrange;
     retain ssa1 'CUSTOMER*D '
              ssa2 'CHCKACCT ';
     infile acctsam dli ssa=(ssa1,ssa2) status=st 
            pcbno=3;

Here the CHCKACCT segment contain 2 occurances from position 160 to 320,  i need to read amount field from position 163 to 170, first occurances i need to read as AMT1 and second occurance i need to read as AMT2 , 

 

I could not find any example from here

http://support.sas.com/documentation/cdl/en/acims/62983/HTML/default/viewer.htm#n10w0tj80b27mfn17odm...

 

Thanks.

SASKiwi
PROC Star

If your source data file genuinely has the duplicates you describe, you first need to set some business rules as to how these should be handled. SAS cannot set these rules and we have no knowledge on how they should be handled.

 

I suggest you consult an ATM transaction expert at your bank to advise you on what to do with duplicates (the business rules), then we can talk about how these can be coded in SAS. Remember we know nothing about your data except what you have posted. You need to explain what to do with the duplicates (keep them, discard them, keep some of them, keep the first, keep the last etc...) before we can move forward.

 

As @Shmuel has asked we would also need sample data.

Cynthia_sas
SAS Super FREQ
Hi:
As you know, IMS is a hierarchical database that is an IBM product. So, when you use SAS/Access to IMS, you basically have to traverse the hierarchy from parent to child in order to retrieve the records you want.

I doubt the OP will be able to post IMS data from the database and it wouldn't help anyway, because you'd need SAS/Access to IMS to read the database.

The documentation for SAS/Access to IMS is here: http://support.sas.com/documentation/cdl/en/acims/62983/HTML/default/viewer.htm#p09e9rotuvawsin1bxuo...

If you have issues reading specific IMS mainframe data files, it may be more expedient for you to open a track with Tech Support.

cynthia
murali_vijayend
Calcite | Level 5

Thanks.

 

Hi,

 

I am using Mainframe BASE SAS, I can see the COPY LIB.

 

I am using INFILE and input statement to read the data.

 

I am using code like below

 

  data distribc;
     length  $11;
     keep ziprange
           check_amount
            balrange;
     retain ssa1 'CUSTOMER*D '
              ssa2 'CHCKACCT ';
     infile acctsam dli ssa=(ssa1,ssa2) status=st 
            pcbno=3;

Here the CHCKACCT segment contain 2 occurances from position 160 to 320,  i need to read amount field from position 163 to 170, first occurances i need to read as AMT1 and second occurance i need to read as AMT2 , 

 

I could not find any example from here

http://support.sas.com/documentation/cdl/en/acims/62983/HTML/default/viewer.htm#n10w0tj80b27mfn17odm...

 

probably i get tech support.

 

Thanks.

 

murali_vijayend
Calcite | Level 5

Thanks.

Patrick
Opal | Level 21

Hi,

 

In case you're dealing with a flat file then such a hierarchical structure could also be read without the SAS/Access Interface to IMS.

 

Do you by any chance have a Cobol Copybook for reading the structure? Are you using DI Studio?

 

Do you want to read all the data into a single de-normalized SAS table or do you want to extract the data into multiple tables?

 

If you're dealing with a flat file: Can you please post some sample data with re-occurences. This would really help to provide you some working sample code.

 

The approach is basically: Have multiple input statement using the @ modifier so you can first determine what kind of record you're dealing with and then branch to the input statement you need for this record.

 

 

 

murali_vijayend
Calcite | Level 5

Hi,

 

I am using Mainframe BASE SAS, I can see the COPY LIB.

 

I am using INFILE and input statement to read the data.

 

I am using example code like below

 

  data distribc;
     length  $11;
     keep ziprange
           check_amount
            balrange;
     retain ssa1 'CUSTOMER*D '
              ssa2 'CHCKACCT ';
     infile acctsam dli ssa=(ssa1,ssa2) status=st 
            pcbno=3;

Here the CHCKACCT segment contain 2 occurances from position 160 to 320,  i need to read amount field from position 163 to 169, first occurances i need to read as AMT1 and second occurance i need to read as AMT2 , 

 

I could not find any example from here

http://support.sas.com/documentation/cdl/en/acims/62983/HTML/default/viewer.htm#n10w0tj80b27mfn17odm...

 

Please let  me know if you any doubt.

 

Thanks.

Patrick
Opal | Level 21

OK, so it's not a flat file but you're actually directly interfacing with IMS using SAS/Access.

 

I believe Example 1: A Get Call could give you some guidance.

http://support.sas.com/documentation/cdl/en/acims/62983/HTML/default/viewer.htm#p1q7ur2j0pcgc0n1ebn6...

 

Sorry, can't be of more help in this situation but just advise you go with what @Cynthia_sas recommended in case you get stuck.

 

Shmuel
Garnet | Level 18

In case of flat file you may develop a code like in attached document.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1774 views
  • 0 likes
  • 5 in conversation