BookmarkSubscribeRSS Feed
Question
Fluorite | Level 6

Hi All,

I would like to match the file attached to anothe file on account_number. This file contains a column called 'Account Number' and another column called 'Order delivery date. But the account number is only populated for the first order. For example if a customer has made 3 orders, the first account number will be populated but the second and third row is missing for account number but it should be the same account number. (We should have duplicates instead of missing).

I have received this file in this format and unfortunately I can't do it manually, It will take ages. I would like to match this file to another file to get the 'Order delivery date, but I will have to sort on account number but I wouldn't know which account number to associate to the missing values. I am not sure if you can see the file attached. If not, please let me know because I am having problems with attachement.

Many Thanks

Account NumberOrder Delivery date
10000000101/01/2012
I should Have here 100000001 instead of missing05/01/2012
I should Have here 100000001 instead of missing10/01/2012
1000000201/01/2012
1000000320/01/2013
1000000415/02/2013
I should Have here 100000004 instead of missing18/02/2013
I should Have here 100000004 instead of missing20/02/2013
1000000515/04/2013
I should Have here 100000005 instead of missing18/04/2013
3 REPLIES 3
AncaTilea
Pyrite | Level 9

Hi.

How about this:

data want;

    set your_data;

  retain temp;

  if accnt_num ne . then temp = accnt_num;

      else if accnt_num =. then accnt_num = temp;

run;

Good luck!

Anca.

Question
Fluorite | Level 6

Thank You Very Much...

Aad
Calcite | Level 5 Aad
Calcite | Level 5

A variation on the above solution which does not use IF statements anymore:

Data WANT (Drop = TEMP);

     Set YOUR_DATA;

     Retain TEMP;

     TEMP = Coalesce (ACCNT_NUM, TEMP);

     ACCNT_NUM = TEMP;
     RUN;

NOTE: If the ACCNT_NUM, though the name sugests otherwise, is a CHARACTER variable, you should replace the Coalesce woth a CoalesceC

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 791 views
  • 1 like
  • 3 in conversation