IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SAS MERGE to DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 577
Location: USA

PostPosted: Mon Feb 01, 2016 7:32 pm
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: 8574
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 01, 2016 8:13 pm
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: 1692
Location: Tiruppur, India

PostPosted: Tue Feb 02, 2016 4:37 pm
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
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: 1692
Location: Tiruppur, India

PostPosted: Tue Feb 02, 2016 7:23 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
Location: Inside the Matrix

PostPosted: Tue Feb 02, 2016 7:53 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts DFSORT to add 6 hours to time(tdate-t... DFSORT/ICETOOL 16
No new posts SOC7 error with DFSORT DFSORT/ICETOOL 9
No new posts Join lines with dfsort DFSORT/ICETOOL 5
No new posts Covert k to 1000 / m to 1000000 using... DFSORT/ICETOOL 5
No new posts DFSORT Output file order query DFSORT/ICETOOL 2
Search our Forums:

Back to Top