BookmarkSubscribeRSS Feed
Sultana
Calcite | Level 5

Hello,

I have a data in CSV format where in the account ID and type are the sources, so I want the output as from account Id take the source as AB Post-Tax and CD PRE-TAX having the amount total but then from the type I need to take the Roth Deferral and SafeMatch also as the source with the amount so where I have 

 

567-67-4444AB Post-TaxRoth Deferral1,234.77

 

The AB Post-Tax is not to be taken instead to take the Roth Deferral and the amount reflected for the same. Please advise. the same is true for SafeMatch. This is just sample data it has 1000 rows as such so I cannot hard code. 

SSNAccountID TypeAmount
123-11-2222AB Post-Tax 1,234.00
345-45-3333AB Post-Tax 1,235.00
567-67-4444AB Post-TaxRoth Deferral1,234.77
789-01-5555CD PRE-TAX 1,254.77
321-11-1111CD PRE-TAX 1,734.77
543-22-6666CD PRE-TAXSafeMatch 1,834.77
3 REPLIES 3
Reeza
Super User

Unfortunately the question is unclear to me. 

Please clearly specify what is the input, what is the expected output and the logic between two steps. 

 


@Sultana wrote:

Hello,

I have a data in CSV format where in the account ID and type are the sources, so I want the output as from account Id take the source as AB Post-Tax and CD PRE-TAX having the amount total but then from the type I need to take the Roth Deferral and SafeMatch also as the source with the amount so where I have 

 

567-67-4444 AB Post-Tax Roth Deferral 1,234.77

 

The AB Post-Tax is not to be taken instead to take the Roth Deferral and the amount reflected for the same. Please advise. the same is true for SafeMatch. This is just sample data it has 1000 rows as such so I cannot hard code. 

SSN AccountID  Type Amount
123-11-2222 AB Post-Tax   1,234.00
345-45-3333 AB Post-Tax   1,235.00
567-67-4444 AB Post-Tax Roth Deferral 1,234.77
789-01-5555 CD PRE-TAX   1,254.77
321-11-1111 CD PRE-TAX   1,734.77
543-22-6666 CD PRE-TAX SafeMatch  1,834.77

 

Sultana
Calcite | Level 5
This is my input data

SSN AccountID Type Amount
123-11-2222 AB Post-Tax 1,234.00
345-45-3333 AB Post-Tax 1,235.00
567-67-4444 AB Post-Tax Roth Deferral 1,234.77
789-01-5555 CD PRE-TAX 1,254.77
321-11-1111 CD PRE-TAX 1,734.77
543-22-6666 CD PRE-TAX SafeMatch 1,834.77

and I want the output data as

Src
Amount
AB Post-Tax 2,469
CD PRE-TAX 1,234.77
Roth Deferral 2,989.54
SafeMatch 1,834.77
[image: image.gif]
ChrisNZ
Tourmaline | Level 20

One way to do this is to use the UPDATE BY statement.

Another is to use a SET KEY= statement or a hash table.

In all cases, you need to ensure there are no duplicates, i.e.  AB Post-Tax only has type Roth Deferral

Using a hash table:

data WANT;
  set HAVE;
  if _N_=1 then do;
   dcl hash H(dataset:'HAVE(where=(TYPE ne " ")) ');
   H.definekey('ACCOUNTID' );
   H.definedata('TYPE');
   H.definedone();
  end;
  if TYPE=' ' then H.find();
run;

 

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 1097 views
  • 0 likes
  • 3 in conversation