Focal Point
NODATA with MATCH
May 05, 2005, 05:30 PM
KameshNODATA with MATCH
Have two tables and Matching it with the option of OLD-OR-NEW .
I need the output has to have N/A if some of the fields dont have data.
EX:
Table1
Name Id Dept
EMP1 1 CSE
EMP2 2 CSE
EMP3 3 ECE
Table2
Id DESCRIPTION
1 COMPUTER SCIENCE
2
3 ELECTRONICS
MATCH FILE TABLE1
PRINT NAME DEPT
BY ID
RUN
FILE
PRINT DESCRIPTION
BY ID
AFTER MATCH HOLD OLD-OR-NEW
END
TABLE FILE HOLD
PRINT NAME ID DEPT DESCRIPTION
END
The final HOLD file has to look like,
NAME ID DEPT DESCRIPTION
EMP1 1 CSE COMPUTER SCIENCE
EMP2 2 CSE N/A
EMP3 3 ECE ELECTRONICS
May 05, 2005, 05:43 PM
k.laneIf the data is missing, why not just set:
SET NODATA = 'N/A'
May 05, 2005, 05:46 PM
reFOCUSingCould you create defined field that checks the value in the dataset?
DEFINE FILE filename
definefield/A20 = IF fieldname IS MISSING THEN 'N/A' ELSE fieldname;
END
I'm guessing SET NODATA = 'N/A' did not work for you.
May 05, 2005, 06:37 PM
KameshYes CurtisA - You are right.
SET NODATA='N/A' - not working.
May 05, 2005, 06:40 PM
KameshCurtisA - I'm not able to use DEFINE bcoz those fields are decimal fields.
May 05, 2005, 06:53 PM
k.laneJust a couple of questions:
Is this just sample data you're using or the real thing? If it's real, then what does the ID represent? Would that be department ID? Employee ID?
I'm confused as to why SET NODATA = 'N/A' isn't working. I tried the same type of report using similar data at my site and nodata worked fine.
Is there a reason why you're using MATCH instead of JOIN in this case?
May 05, 2005, 07:19 PM
Kameshthat's the sample data.
The reason I'm using MATCH is, I need all the records in TABLE1 and the corresponding records from TABLE2.
Sometimes TABLE2 may have zero records.
May 05, 2005, 07:23 PM
k.laneIf you need all the records from Table1 then JOIN should work for you. If you need to, SET ALL=PASS.
SET ALL = PASS
JOIN CLEAR *
JOIN ID IN TABLE1 TO ID IN TABLE2
I would expect you to use MATCH if there are records in table2 that are not in table1.
May 05, 2005, 09:21 PM
Kameshtried JOIN, still NODATA didn't work.
The field I'm trying to get N/A is Padded fields. Do you think it may be the problem?
May 05, 2005, 09:44 PM
k.lanePadded fields?
May 05, 2005, 10:29 PM
KameshDecimal fields
May 06, 2005, 02:57 PM
TerryWOK, since you have a Decimal field, but want to print an Alpha value, then use a DEFINE with an EDIT, very similar to what CurtisA suggested earlier.
DEFINE FILE filename
alphafield/A20 = IF decimalfield IS MISSING THEN 'N/A' ELSE EDIT(decimalfield);
END
May 06, 2005, 05:55 PM
KameshI want to display a decimal value with '$' sign. If I use EDIT, then it will truncate decimal part of it.
May 06, 2005, 06:29 PM
TerryWHow about adding the '$' via concatenation?
DEFINE FILE filename
alphafield/A20 = IF decimalfield IS MISSING THEN 'N/A' ELSE '$' | EDIT(decimalfield);
END
May 06, 2005, 07:03 PM
TerryWOops, sorry. I was Focus'ing in (pun intended) on the '$' and not the 'truncate decimal part'. So try this instead:
DEFINE FILE filename
alphafield/A20 = IF decimalfield IS MISSING THEN 'N/A' ELSE FTOA(decimalfield, '(D12.2M)', 'A14');
END
May 06, 2005, 07:11 PM
KameshThe problem is, when MATCH or JOIN two tables. It is not identifying the MISSING data, it simply says 0 for those.
May 06, 2005, 09:03 PM
TerryWIf it has a 0, then change the words "IS MISSING" to "EQ 0" in the DEFINE.
This seems to be way harder than it should be. Are we mis-understanding? Maybe we need more of the code causing the problem, with the actual output versus the expected output.
May 07, 2005, 07:21 AM
<JG>Got to ask the obvious question.
What are the data sources? relational DB, Focus, Flat file.
And is the column in question declared as MISSING ON in the master file.
May 09, 2005, 09:37 PM
k.laneAnother obvious question. Does the field you are checking for missing contain spaces or a 0 or is it in fact missing?
May 09, 2005, 09:42 PM
k.laneSomething I forgot to ask. In your first posting, you indicated that your data looked something like the following:
Name Id Dept
EMP1 1 CSE
EMP2 2 CSE
EMP3 3 ECE
Table2
Id DESCRIPTION
1 COMPUTER SCIENCE
2
3 ELECTRONICS
...with the report showing N/A under the description. However you've also indicated that you're checking a decimal field. Are you checking for ID?