BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

 

Hello

Lets say that I have data set A and every day I create another data set called B and then I want to add the rows of B to A.

I want to show 2 ways and ask which way is better ?

 


/*Way1*/
Data A;
SET A B;
Run;
/*Way2*/
Data tempTbl;
SET A;
Run;
Proc delete data=A;Run;
Data A;
SET tempTbl B;
Run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Ronein wrote:

 

Hello

Lets say that I have data set A and every day I create another data set called B and then I want to add the rows of B to A.

I want to show 2 ways and ask which way is better ?

 


/*Way1*/
Data A;
SET A B;
Run;
/*Way2*/
Data tempTbl;
SET A;
Run;
Proc delete data=A;Run;
Data A;
SET tempTbl B;
Run;

 


Proc append if the data sets have the same variables with the same lengths for character variables would be the better choice.

Anything involving a data step reads each and every record. Which means your "Set A B"; runs slower and slower as A bets bigger.

Proc Append works a bit differently and will typically run much faster for this type of activity.

 

If the variables are not the same then the first way would be more efficient in resources.

View solution in original post

1 REPLY 1
ballardw
Super User

@Ronein wrote:

 

Hello

Lets say that I have data set A and every day I create another data set called B and then I want to add the rows of B to A.

I want to show 2 ways and ask which way is better ?

 


/*Way1*/
Data A;
SET A B;
Run;
/*Way2*/
Data tempTbl;
SET A;
Run;
Proc delete data=A;Run;
Data A;
SET tempTbl B;
Run;

 


Proc append if the data sets have the same variables with the same lengths for character variables would be the better choice.

Anything involving a data step reads each and every record. Which means your "Set A B"; runs slower and slower as A bets bigger.

Proc Append works a bit differently and will typically run much faster for this type of activity.

 

If the variables are not the same then the first way would be more efficient in resources.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 468 views
  • 2 likes
  • 2 in conversation