Hi !
The code below helps me to pick the last timestamp record whereas i want the latest one.
Example :
An account A1 have 2 email ids E1 with Timestamp 12/20/2020 12 :30:00 and E2 with Timestamp 09/02/2020 12 :10:00 then it should pick the E1 record but in my code it will pick E2 as it is the last one.
Please highlight the changes I need to do in below code.
*****************************************************************************************************************
libname rpl "/stage_1/download/backup/adhoc/kyccrs/083020/bestbuy_dcfaccess_weekly";
options obs = max yearcutoff=1940;
%macro a;
(KEEP = WS_ACCT_NUM WS_EMAIL_ADDR_LAST WS_EMAIL_ADDR)
%mend;
data rpl_dcf;
set rpl.bbrdcf_eaddr083020;
set rpl.bbrdcf_eaddrpii083020;
run;
Proc sort data =rpl_dcf;
by WS_ACCT_NUM WS_EMAIL_ADDR_LAST ;
run;
/* using last account that is sorted by account & timestamp. */
data all;
set rpl_dcf;
by WS_ACCT_NUM;
if last.WS_ACCT_NUM ;
run;
Proc sort data =all;
by WS_ACCT_NUM WS_EMAIL_ADDR_LAST ;
run;
data all;
RETAIN WS_ACCT_NUM WS_EMAIL_ADDR_LAST WS_EMAIL_ADDR ;
set all %a;
run;
proc export data = all
outfile="/etl/home/rrtqarun/data/aml/Datasets/cardholder/dataset_frequency/trial083020.csv"
dbms=csv
replace;
delimiter= '|';
run;
*****************************************************************************************************************
help will be appreciated
No format means that this can only be a character variable (look at the type).
Dates or times as character are mostly useless in SAS. Convert this to SAS datetime values first, ideally in the step that gets the data into SAS in the first place.
This can only happen if your timestamps are stored in character variables and not as SAS datetime values.
Maxim 3: Know Your Data. Run a PROC CONTENTS on the dataset and inspect the attributes of your timestamp variable.
No format means that this can only be a character variable (look at the type).
Dates or times as character are mostly useless in SAS. Convert this to SAS datetime values first, ideally in the step that gets the data into SAS in the first place.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.