Hi,
I have SAS datasets like this attached image. Based on FILENAME I am able to import as SAS datasets from source. Once after that I would like compare datasets based on COL1 and COL2 group as per the prefix file name. This will be as dynamic process. So the file name might be differ in next month. It shouldn't hard coded. We might be receiving same prefix name files with in a month twice or thrice in different dates. So how to compare two different SAS datasets to find out if there are any records difference.
For example:
ABC_20200909_INITIAL
ABC_20200901_INITIAL
I would like to know some sample Macro to do this. Could you please provide me?
What exactly do you want to compare?
What might the expected output look like?
If Col1 and Col2 are built from the data set names I find the order of the numbering extremely odd.
If you are indeed looking at SAS data sets then there would be no macro needed at all. SAS maintains characteristics of all the SAS data sets available and the list is searchable. The question might be "in what library do these data sets reside"?
Scenario1:
There might be one or more files for a month, if the Practitioner is listed on the monthly file generated previously and the same is listed in the current file without any changes, then update the date to the latest file generated date in 'File Date' column.
File Date column I have extracted in my above screenshot document which is date variable.
Scenario2:
Practitioner is listed on the monthly file generated previously and the same is listed in the current file with any changes/updates, then update it as a new record with file generation date in file date column, where the old record remains same.
Example:
Group1.
ABC_20200909_INITIAL
ABC_20200901_INITIAL
Group2.
ABC_20200909_RECRED
ABC_20200909_RECRED
Note: The comparison should happen based on file prefix and suffix name. It seems we have same prefix but suffix is changed.(INITIAL AND RECRED)
This will be as dynamic process. So the same file might not be fall in next month. It can be some other file as well. It shouldn't hard coded. I have given screenshot is one of the example.
Data sets will reside work library.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.