I have 3 datasets and each having 4 variables .......and setting them together..
The variables are not in order in each. they are jubbled and I am setting them together without formatting
these variables are also of not equal lengths and formats
After setting the three of them in the final resultant dataset follow the first dataset(in terms of length of variables, formats) etc etc
Also since for example the second variable in dataset2 is A will it go back to 1st oposition automatically after setting?????and so on??
dataset1
A B C D
dataset2
B A C D
dataset3
D A B C
data want;
set dataset1 dataset2 dataset3;
run;
Thanks
SAS will set the order and other attributes as soon as it can.
So the first reference to a variable will set its order.
The first reference that causes SAS to assume a type and length will set those.
The first referenced dataset with an attached format or label will set the label, but the last actual format or label assignment by code will override what it might decide from reading source datasets.
In your example the order will be A B C D because of DATASET1. The type and length will also match that in DATASET1. SAS will move the values read from the other datasets around to put them in the right place.
Not exactly clear on your issue.
In simplistic terms, SAS sets the under based on the order of seeing the variables. So the first dataset read will set the order of the variables. If you declare the variables in a length statement you can control the order and set the maximum length you need across the three datasets.
If this doesnt help you might need to provide for information or a clearer question so the community can follow up.
EJ
So even the second dataset has B A C D order its gona become ABCD and gets apended?????
Regards
Unlike sql, SAS data step appends based on the variable names in the dataset and not the ordering of the variables in the sources.
EJ
SAS will set the order and other attributes as soon as it can.
So the first reference to a variable will set its order.
The first reference that causes SAS to assume a type and length will set those.
The first referenced dataset with an attached format or label will set the label, but the last actual format or label assignment by code will override what it might decide from reading source datasets.
In your example the order will be A B C D because of DATASET1. The type and length will also match that in DATASET1. SAS will move the values read from the other datasets around to put them in the right place.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.