SAS can read or import and write/export to CSV. SAS compares SAS data sets. So SAS really does not "compare" CSV files.
I hope your data sets after import/reading actually have a grade variable or combining them without one is extremely likely to limit your analysis and reporting options.
And depending on some data sources I would NOT actually expect the header rows to be the same even if the layout is the same. There are entirely too many folks happy to have a column header like "Enrollment 5th Grade" , "Fail Grade 5" or similar with the grade changing in each file
A way to use proc import to help with this sort of thing if the files are supposed to be of the same structure is to:
1) Use proc import to import one file with GUESSINGROWS=MAX.
2) Proc import will generate data step code to read a csv file. Copy it from the log into the editor.
3) verify that the expected fields have the correct types. If you have a character value that might be longer in some files, such as a school name, make sure that the generated informat is long enough to read the longest expected value (and I usually add 5 or 10 characters just in case), make sure dates have an appropriate informat and associated format. Things like Zip codes, accounts or identification fields should almost always be character and not numeric as the guessing procedures like import will do for numeric digit coded identifiers.
4) add appropriate labels
5) you may want to add code to add something like grade
6) Then the code could be wrapped in a macro changing the infile statement as you are using it and the output data set name and if needed perhaps even use your macro variable &num to assign a value to the grade variable if not in your data set
... View more