We're working with SAS here, not with Excel 😉
So please post data the SAS way, as DATA step code with datalines. In many professional environments, download of Office files is prevented for security reasons, and Excel file sdo not show us the variable attributes of your real dataset(s).
Instead of showing us the transposed dataset (which is much harder to work with), post the original "long" dataset.
Something like this, I suppose:
data want;
set have;
array dates(*) date_1-date_10;
do _N_=1 to dim(dates);
if missing(dates(_N_)) then continue;
if dates(_N_)<_date then do;
output;
leave;
end;
_date=dates(_N_);
end;
drop _date;
run;
Please show the long dataset, and post working code. You need a DATALINES statement and proper informats (use the INFORMAT statement) for at least the dates.
I take it that your original dataset contains at least three variables: subject, visit, date.
Sort by subject and visit (if you have visits with missing dates, remove them here with a dataset option); then, compare date with lag(date) to see if there's an incorrect order.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.