BookmarkSubscribeRSS Feed
kanga
Calcite | Level 5

Hello, I have a data set, that looks like a change log.  Each document number can have 30-50 lines but the document code can be different on each line. Example below...  How can I say I want Document numbers that do not have Document cd DEF but do have document code EFG? 

 

Document CdDocument number
ABC103013013013
BCD103013013013
EFG103013013013
ABC103013013013
QRS103013013013
QRS103013013013
ABC103013013013
DEF103013013013
9 REPLIES 9
PaigeMiller
Diamond | Level 26

How can I say I want Document numbers that do not have Document cd DEF but do have document code EFG? 

 

This is the same as asking for document codes equal to EFG, is it not?

 

proc sql;
    create table want as select * from have where document_cd='EFG';
quit;

 

--
Paige Miller
kanga
Calcite | Level 5

But I only want it if there is no DEF associated with the Document number.

novinosrin
Tourmaline | Level 20

"How can I say I want Document numbers that do not have Document cd DEF but do have document code EFG? "

 

What do you mean?

 

What do you want as output for the sample you posted?

kanga
Calcite | Level 5
I want a listing of document numbers that have one of the document codes but not the other. (looking for a type of process that is incomplete)
PaigeMiller
Diamond | Level 26

@kanga it would help if you showed us a meaningful example, where the document numbers are not all equal, and also show us the output desired.

--
Paige Miller
kanga
Calcite | Level 5

Here is subset of the actual data set.  I want a listing of all DOC_Num that have a DAC in Type Field but do not have an FN2

 

Typedoc_numqtypricedtgrp
FTEFT6261712371122550.05201705
DWBFT62617123711225517.87201705
FTRFT626171237112255 201705
FT6FT626171237112255 201706
FTFFT62617123711225517.87201706
FTRFT626171237112255 201706
FTMFT6261712371122550.02201706
D6BFT62617123711222517.87201707
FTRFT62617123711222529.48201707
FTZFT6261712371122250.29201707
DACFT6261712371122300.29201708
FTRFT62617123711222517.87201708
FT6FT62617123711225 201708
FTZFT6261712371122304.92201802
FN2FT626171237112250.06201802
FQ2FT626171237112200.06201806
D6AP947Z0229001771130.02201707
FN2P947Z022900177113 201804
FQ2P947Z022900177113 201804
FT6P947Z022900177113 201704
FTBP947Z022900177113 201705
FTEP947Z022900177113 201704
FTMP947Z0229001771130.09201708
FTPP947Z022900177113 201705
FTRP947Z02290017711363.2201708
FTZP947Z022900177113392.79201707
FN2P947Z0229001771130.09201708
FQ2P947Z0229001771130.09201709

 

PaigeMiller
Diamond | Level 26
proc freq data=have;
by doc_num;
tables type/noprint list out=b;
run;

proc transpose data=b out=c;
by doc_num;
var count;
id type;
run;

data want;
    set c(where=(dac>0 and fn2<1));
run;
--
Paige Miller
kanga
Calcite | Level 5
Thank you!!!!
novinosrin
Tourmaline | Level 20

Hello @kanga 

 

Assuming I Understand-->

 


proc sql;
create table want as
select *
from have
group by Document_number
having max(Document_Cd='DEF')=0 and max(Document_Cd='EFG')=1;
quit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 5516 views
  • 0 likes
  • 3 in conversation