Hi ,
I have 20 datasets which share the same variables between them.
Is it better to use Append or Set statements to combine tthem all into a single dataset?
Also that resulting dataset needs to be Updated every month with fresh info
Could you help me figure this
Thanks
I search support.sas.com for "proc append samples"
Here are some that may be applicable:
Sample 48810: Append all SAS data sets in a SAS library into 1 SAS data set when the number of SAS data sets varies
http://support.sas.com/kb/48810
Sample 45143: Error trapping with PROC APPEND
http://support.sas.com/kb/45143
Sample 25291: Adding new observations to a SAS data set using PROC APPEND
http://support.sas.com/kb/25291
Sample 33407: Combining Data Sets Containing Character Variables of Different Lengths
http://support.sas.com/kb/33407
One of these may give you ideas to get started.
Cheers,
Jan
Maybe SET with OPEN=DEFER. Check the docs for complete info.
Do any of the variables of the same name have different types (numeric or character)?
Do any of the character variables have different assigned lengths?
If yes to either of these questions you need to address them before either option or you will not be happy with the results.
APPEND may be more efficient in the long run, but it has less flexibility.
hi can u help me as to where i can find book "sas macro language 1 essentials"
Here is the link
I'm a bit confused about your statement "resulting dataset needs to be Updated every month with fresh info".
What kind of update is that? Is the repeated append/set operation?
If not, is this concatenation a one time shot? Then there is no need to investigate about efficiency...
robertrao,
I guess you must have some variables that define the class or a group.
Is it possible in your case that two diffrerent datasets have at least one row with equal class variables and different properties?
Like...
Date Price
01JAN2010 100 in dataset 1
01JAN2010 200 in dataset 2
If it is and your datasets are not really big consider using merge instead of set or append: then you will have only one value for each class set by the last dataset you merged.
In general, PROC APPEND is more efficient because it merely opens the base data set and adds the additional observations to it.
When you use SET to concatenate data sets, as here:
data base;
set base newdata;
run;
you are rewriting all the base observations in addition to the new data. When your data sets are small, this is not important. However, as the base data set gets larger, you wll find the process taking longer and longer.
As Art Carpenter noted, the SET method allows you to apply program logic to the concatenation and is far more flexible than PROC APPEND.
If speed and efficiency are critical, and you simply want to add the observations, use PROC APPEND.
If you require flexibility and program logic, use SET statement.
If you want to summarize statements on key variable(s), use MERGE statement as suggested by @ghastly_kitten
Cheers,
Jan
I search support.sas.com for "proc append samples"
Here are some that may be applicable:
Sample 48810: Append all SAS data sets in a SAS library into 1 SAS data set when the number of SAS data sets varies
http://support.sas.com/kb/48810
Sample 45143: Error trapping with PROC APPEND
http://support.sas.com/kb/45143
Sample 25291: Adding new observations to a SAS data set using PROC APPEND
http://support.sas.com/kb/25291
Sample 33407: Combining Data Sets Containing Character Variables of Different Lengths
http://support.sas.com/kb/33407
One of these may give you ideas to get started.
Cheers,
Jan
Hi,
I have a couple of questions in the following link...
http://support.sas.com/kb/48810
proc contents data=abc._all_ out=abccont(keep=memname) noprint; /*what does the memname refer to*/
run;
ALSO
%macro combdsets;
%do i=1 %to &count;
proc append base=new data=abc.&&name&i force; /*after running this macro step "NEW" dataset is created which has all the datasets???*/
run;
%end;
%mend combdsets;
Start a new thread and clarify your questions please.
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.