After writing programs for my client that look for dirty data, they like to run test data through the program if the report comes out empty. We get test data by exporting the raw SAS data into Excel so the data manager can modify it. I try to read this back into SAS to run through my programs, but when I read in from Excel to SAS, it doesn't always end up with the exact same data structure (e.g., dates might be different formats, leading zeroes are lost, decimal precision might be different, and variable lengths might be different). I'm writing a bit of code that will read in a test file, compare it to the raw data it was taken from, and format each variable to match exactly so when I run it through the program I don't end up with errors/warnings. The loss of leading zeroes causes issues because if my code is merging a raw dataset with a test dataset by SITEID and the raw data has SITEID='001' and the test data has SITEID='1', then it won't find a match, and the test data becomes pointless.
Maybe I'm making more of an issue out of this than I need, but I can't find a better way to do this. There are times where the amount of test data is minimal, so I will do something like:
data test;
set raw; if subjid='001-101-101' then do; /* manually type changes to the data */ end; run;
If there are better ways to do test data, I will gladly accept any help!
... View more