Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- Re: SET OR APPEND?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-27-2013 01:43 PM
(2992 views)

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

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

11 REPLIES 11

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Maybe SET with OPEN=DEFER. Check the docs for complete info.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

APPEND may be more efficient in the long run, but it has less flexibility.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

hi can u help me as to where i can find book "sas macro language 1 essentials"

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here is the link

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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...

Data never sleeps

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

**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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Start a new thread and clarify your questions please.

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

What is Bayesian Analysis?

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.