BookmarkSubscribeRSS Feed
Swapnil_21
Obsidian | Level 7

Hi,

I have one dataset as below named Have 

Var1 Var2 Var3

10 20 30

40 50 60

 

I need to append 2 variables to dataset which is already present and has structure and data as below

Appended_table

Var2 Var4

100 200

300 400

 

 

Data want ;

set have;

var4=var1*2;

/*Above step is the operation to be done */

 

/* I want Var1 and var4 to be appended in Appended table mentioned below*/

;

run;

 

Below is the output that I want in Appended_table dataset

 

Appended_table

Var2 Var4

100 200

300 400

20 40

50 100

 

I tried both proc append and creating the macro variable but somehow could not get it right. Any help is really appreciated.

3 REPLIES 3
Tom
Super User Tom
Super User

It is not clear what you want to do but it looks like you want to generate data from HAVE and append it to APPENDED_TABLE.

 

data want ;
  set have;
  var4=var2*2;
  keep var2 var4;
run;

proc append data=want base=appended_table;
run;

 

 

PaigeMiller
Diamond | Level 26

I am extremely confused.

 

What do you mean by "append"? It seems as if you are using "append" to describe what you are doing with variables and also the same word "append" is describing what you are doing to two data sets.

--
Paige Miller
Oligolas
Barite | Level 11
data have;
input var1-var3;
cards;
10 20 30
40 50 60
;
run;

data Appended_table;
input var2 var4;
cards;
100 200
300 400
;
run;

data Appended_table2;
   set Appended_table have(in=a) ;
   if a then var4=var1*2;*Did U mean var4=var2*2 ?;
   keep var2 var4;
run;
proc print;run;
________________________

- Cheers -

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 752 views
  • 0 likes
  • 4 in conversation