BookmarkSubscribeRSS Feed
saslovethemost
Quartz | Level 8

Hi all,

 

Following is the code iam using

 

data inptxn;

infile intxn;

input

@001 full_rec $259.

@001 txns_rec $238.

@007 lnno $09.

@016 cycno yymmdd6.

@085 prindue zd11.2

@121 corrind $1.

@215 crtmt zd11.2

@227 bic zd11.2

@241 dt_tm $10.

;

key = lnno||cycno;

run;

proc sort data=inptxn; by key descending dt_tm;

run;

data intxn1;

set inptxn;

by key corrind descending dt_tm;

if first.key and last.key then

output intxn1;

else

do;

if corrind= 'Y' then

output intxn1;

else if first.key then

output intxn1;

end;

run;

data _null_;

set inptxn1;

file ottxn;

put txns_rec;

run;

 

2 REPLIES 2
saslovethemost
Quartz | Level 8

Sorry before I write the message, I posted it.

 

Below is the code I am using it, I want to get the output recods if there are two records with same ln_no and cycno then if the corrn_ind is Y then I want to output that record, the corrn ind should take the preedence over the dt_tm.if there is no corrn_ind then the latest and greatest with the dt_tm should be otputed.

 

Appreciate any help on this. TIA.

 

ballardw
Super User

@saslovethemost wrote:

Sorry before I write the message, I posted it.

 

Below is the code I am using it, I want to get the output recods if there are two records with same ln_no and cycno then if the corrn_ind is Y then I want to output that record, the corrn ind should take the preedence over the dt_tm.if there is no corrn_ind then the latest and greatest with the dt_tm should be otputed.

 

Appreciate any help on this. TIA.

 


When providing anything with a complex, and especially requiring comparisons across records, you should provide a clear example of start and end for each type of condition so we can see what you are actually comparing and wanting for output. Also your request mentions conditions using variable "corrn_ind" but the data set does not have a variable of that name but does have "

corrind", are these supposed to be the same?

 

Also it really is not necessary to attach separate files for short text examples. Use a datalines or cards statement to indicate inline data. It helps to post example code in a code box using the forum {i} menu icon to preserve formatting such as:

data inptxn;
   input
      @001 full_rec $259.
      @001 txns_rec $238.
      @007 lnno $09.
      @016 cycno yymmdd6.
      @085 prindue zd11.2
      @121 corrind $1.
      @215 crtmt zd11.2
      @227 bic zd11.2
      @241 dt_tm $10.
   ;
   key = lnno||cycno;
datalines;
441005367940841170415TEST06       2153208466          10090100000000000+00000066471+00028293581+7117021500000000000+    Y063750000+00000186850+2E3006     100915SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 1704181430         �
441005373065728170415TEST07       2153208466          14090100000000000+00000039830-00029381662+7317022100000000000+     050000000+00000144486+2E3006     140925SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 1704181430         �
877903175597502170415TEST03       2064616416          15080100005182752+00000000000+00000030000-80      00000000000+    Y073750000+00000053618+2E3000     160830JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903175597502170415TEST03       2064616416          15080100005182752+00000000000+00000000000+        00000000000+    Y073750000+00000053618+2E3000     160830JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903199994811170415TEST04       2064616416          17030100000000000+00000000584+00000201604+6017040900000000000+    Y031250000+00000067551+2E3000     170409JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 1704181430         �
877903019354533170415TEST02       2064616416          17010100005064370+00000025482+00000010000-80      00000000000+    Y063750000+00000065777+2E3000     170407JPMORGAN CHASE BANK, N.A. F/K/00005064370+00000000000+00000000000+00000000000+ 1704181430         �
877903180878441170415TEST03       2064616416          17020100005182752+00000000000+00000000000+        00000000000+     073750000+00000053618+2E3000     170208JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903180878441170515TEST03       2064616416          17020100005182752+00000000000+00000000000+        00000000000+     073750000+00000053618+2E3000     170208JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903158072200170415TEST03       2064616416          17020100005182752+00000000000+00000000000+        00000000000+     073750000+00000053618+2E3000     170208JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903158072200170515TEST03       2064616416          17020100005182752+00000000000+00000000000+        00000000000+    Y073750000+00000053618+2E3000     170208JPMORGAN CHASE BANK, N.A. F/K/00005182752+00000000000+00000000000+00000000000+ 1704181430         �
877903158072200170515TEST02       2064616416          17010100005064370+00000025482+00000050000-80      00000000000+     063750000+00000065777+2E3000     170407JPMORGAN CHASE BANK, N.A. F/K/00005064370+00000000000+00000000000+00000000000+ 1704181430         �
183181122492196170415TEST03       0000000000          15080100005182752+00000000000+00000000000+        00000000000+     073750000+00000053618+2E4002     160830LAKEVIEW LOAN SERVICING, LLC  00005182752+00000000000+00000000000+00000000000+ 1704181430         �
87790326145409917041500000047325242064616416          17060100000000000+00000156767+00050918623+6117032200000000000+     041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
87790326145409917041500000047325242064616416          17060100000000000+00000156767+00050918623+6117032500000000000+    Y041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
44100514379818917041500000047325242153208466          17060100000000000+00000156767+00050918623+80      00000000000+     041250000+00000267769+2E3006     170612SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
44100514379818917041500000047325242153208466          17060100000000000+00000156767+00050918623+        00000000000+     041250000+00000267769+2E3006     170612SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
44100536794084117041500000047325242153208466          17060100000000000+00000156767+00050918623+72      00000000000+     041250000+00000267769+2E3006     170612SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  110�
44100537306572817041500000047325242153208466          17060100000000000+00000156767+00050918623+7117010200000000000+    Y041250000+00000267769+2E3006     170612SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
44100543091259517041500000131231432153208466          17060100000000000+00000037000+00014328964+6117063000000000000+    Y035000000+00000065067+2E3006     170605SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  352�
44100500080822917041500000131231432153208466          17060100000000000+00000037000+00014328964+6017063000000000000+     035000000+00000065067+2E3006     170605SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  352�
44100543091259517041500000131231432153208466          17060100000000000+00000037000+00014328964+6017032800000000000+     035000000+00000065067+2E3006     170605SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  252�
87790319999481117041500000047325242064616416          17060100000000000+00000156767+00050918623+6517031600000000000+     041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
87790319999481117041500000131231432064616416          17060100000000000+00000037000+00014328964+6117031600000000000+     035000000+00000065067+2E3000     170605JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  352�
87790301935453317041500000047325242064616416          17060100000000000+00000156767+00050918623+        00000000000+     041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
87790301935453317041500000047325242064616416          17060100000000000+00000156767+00000020000-8017063000000000000+    Y041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  720�
87790302926745517041500000047325242064616416          17060100000000000+00000156767+00050918623+7117020100000000000+    Y041250000+00000267769+2E3000     170612JPMORGAN CHASE BANK, N.A. F/K/00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
44100512238180717041500000047325242153208466          17060100000000000+00000156767+00050918623+6717063000000000000+     041250000+00000267769+2E3006     170612SOVEREIGN BANK                00000000000+00000000000+00000000000+00000000000+ 17041814300000  710�
;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 2 replies
  • 1036 views
  • 0 likes
  • 2 in conversation