I have 2 set of data, 1 in CSV and 1 in XLSX.
Would like to know same data but data type different (CSV vs. XLSX), but why SAS output columns sequence different?
CSV format:
I import 3 CSV data in SAS and perform data merging into 1.
output result:
Column a b c
XLSX format:
I import 2 XLSX data in SAS and perform data merging into 1.
output result:
Column b c a
Without seeing the source data AND how you import and merge things this question really can't be answered.
If you use proc import and the order of columns in the original files is the same what you state is very unlikely to happen though the specific syntax of how you "merge" the data may have an affect.
If the columns of data in different files, the CSV and XLSX, are in different order than that would be a very likely cause.
People creating XLSX files are pretty notorious for having orders of columns change without notice
@CHEESE123 wrote:
yes... I am use proc import.
May I know is there any way for me to reorder the output column?
I have arrange the column seq in SAS(column a b c), then perform output the result in excel. But the column is back to the incorrect order (column b c a).
Show the code you are using.
I suspect that your "arrange the column seq" isn't doing what you think but I'm not going to guess what you may have tried.
You can force order of variable by entering a statement next to DATA statement,
either:
data <output>;
retain <list of variables in desired order);
.....
run;
or:
data <output>;
format <ordered list>; /* without assigning formats */
thus, by mentioning the variable names as first statement, the output should be in same order.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.