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