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.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.