Hello Experts,
I have a datasets which has a lot of information. I have imported an excel file (Nov_BF) which has just 43 account numbers (Account_ID). I want to see if these 43 account number are available in the Finrep_sorted dataset or not. I would also like to add all the variables from Finrep_sorted for these 43 accounts from Nov_BF. Here is the sample dataset:
Data Finrep_sorted;
infile cards expandtabs;
input ACCOUNT_ID FINREP_CURR_SEGMENT$ FINREP_CURR_SEGMENT_REASON$ SOURCE_SYSTEM_CD$ MONTH;
datalines ;
1000032 PERFORMING MEETREQUIREMENTS AF 202311
1000040 PERFORMING MEETREQUIREMENTS AF 202311
1000278 PERFORMING MEETREQUIREMENTS AF 202311
1000307 PERFORMING MEETREQUIREMENTS AF 202311
5464782 PERFORMINGFORBORNE PROBATIONNOTENDED AF 202311
5320998 NON-PERFORMING CONTAGION AF 202311
;
run;
I want the output data to show all the matching accounts and all the variables from Finrep_sorted. I tried merging them and then find but my code gives an error. Please guide.
Data merged_data;
Merge Nov_BF (In=InNov_BF)
Finrep_sorted (In=InFinrep_sorted);
by ACCOUNT_ID;
If InFinrep_sorted; /* Filter to include only matching account numbers */
run;
Error message:
28 Data merged_data;
29 Merge Nov_BF (In=InNov_BF)
30 Finrep_sorted (In=InFinrep_sorted);
31 by ACCOUNT_ID;
32 If InFinrep_sorted; /* Filter to include only matching account numbers */
33 run;
ERROR: BY variable ACCOUNT_ID is not on input data set WORK.NOV_BF.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.MERGED_DATA may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set WORK.MERGED_DATA was not replaced because this step was stopped.