View previous topic :: View next topic
|
Author |
Message |
Musab Ahmed
New User
Joined: 10 Dec 2012 Posts: 37 Location: India
|
|
|
|
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 |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
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 |
|
|
Musab Ahmed
New User
Joined: 10 Dec 2012 Posts: 37 Location: India
|
|
|
|
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 |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|