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
 

 

SAS MERGE to DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Musab Ahmed

New User


Joined: 10 Dec 2012
Posts: 37
Location: India

PostPosted: Mon Feb 01, 2016 5:44 pm    Post subject: SAS MERGE to DFSORT
Reply with quote

I am currently assigned to a project to migrate SAS written code to DFSORT/PL1.

I came across the MERGE statement in SAS which is as follows:

MERGE inp01(in=a) inp02(in=b); by PAX_JNCD;

IF A & B THEN;process;

where inp01 and inp02 are two SAS datasets having a common variable PAX_JNCD.

To convert this to DFSORT, May i perform a JOIN on the two datasets with PAX_JNCD as a key and then reformat the matched records accordingly? Is my approach correct?

That is SAS MERGE BY can be implemented as a JOIN in DFSORT??
Back to top
View user's profile Send private message

sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Mon Feb 01, 2016 7:32 pm    Post subject:
Reply with quote

Musab Ahmed,
Please describe what you need and not provide what's present and perceived by you. Many users here may not know SAS.

Yes SAS MERGE BY can be performed by DFSort.
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 Feb 01, 2016 8:13 pm    Post subject:
Reply with quote

The snippet you posted does the process when the indicated values (PAX_INCD) is the same on both files. There is no indication what happens when the value exists only on one file. DFSORT can handle such a condition via the JOIN.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Tue Feb 02, 2016 4:37 pm    Post subject:
Reply with quote

If the SAS merge is a MANY to MANY merge then you would have problems mimicking it via DFSORT.
i.e. When you have duplicate values for key variables in both input files simultaneously.

DATA step merge does not generate a cartesian product of the merged values when it comes to MANY to MANY merges.
One symptom to diagnose this scenario is via SASLOG where there would be a NOTE saying
Code:
“NOTE: MERGE statement has more than one data set with
repeats of BY values”
Back to top
View user's profile Send private message
Musab Ahmed

New User


Joined: 10 Dec 2012
Posts: 37
Location: India

PostPosted: Tue Feb 02, 2016 7:14 pm    Post subject:
Reply with quote

Hi,

Yes I tried replicating the code with DFSORT JOIN keys concept and it gave a cartesian product which is not the case with SAS MERGE.

Need to think of some other possibility of doing this.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Tue Feb 02, 2016 7:23 pm    Post subject:
Reply with quote

Maybe show us sample input and output files. And the scenario for merge.
Some of the DFSORT Gurus might be able to help you out.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Feb 02, 2016 7:53 pm    Post subject: Reply to: SAS MERGE to DFSORT
Reply with quote

You need to describe exactly what you want instead of a cartesian product, with, as has been mentioned, representative sample input and expected output.
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 -> DFSORT/ICETOOL 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 get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Symbolic Parameters in SYSIN DD state... madishpa DFSORT/ICETOOL 3 Mon Jun 27, 2016 6:23 pm
No new posts SQL Merge error -254 Robin Sulsona DB2 8 Wed Jun 01, 2016 8:28 pm


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