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

Showing results for

Find a Community

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-27-2013 01:43 PM

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

Accepted Solutions

Solution

04-03-2013
03:12 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-03-2013 03:12 PM

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

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-27-2013 01:49 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-27-2013 05:57 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-27-2013 11:28 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2013 11:46 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2013 02:48 PM

Here is the link

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-28-2013 03:48 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-29-2013 01:43 AM

**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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-29-2013 10:42 AM

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

Solution

04-03-2013
03:12 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-03-2013 03:12 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-03-2013 03:45 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-03-2013 03:54 PM

Start a new thread and clarify your questions please.