DATA Step, Macro, Functions and more

How to add a new column in existing dataset

Reply
Occasional Contributor
Posts: 12

How to add a new column in existing dataset

Hello,

 

I want to add new columns to an existing dataset. The new column should contain the data from another dataset. 

 

Here it looks like this

 

 

data sumOut;
set work.dresssales1;
sumvar=sum(_29_8_2013,_31_8_2013);
run;

 

I want to add the value that is stored in sumvar to a new dataset Retail. How do I do this ?

 

Regards,

 

Aditya

 

 

 

Super User
Posts: 10,483

Re: How to add a new column in existing dataset

Do you have variables in both data sets to identify which records are supposed to align such as a product identifier, store identifier, dates or possibly multiple variables? If you have those key variables are combinations of them duplicated within one or both of the data sets?

 

It would be better to provide examples of BOTH data sets. This link https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... has instructions on how to make data step code to replicate the data that you can post here or attach as a TEXT file.

It is also a very good idea to provide an example of what your are looking for as a result in case your narrative description is incomplete.

Ask a Question
Discussion stats
  • 1 reply
  • 3111 views
  • 1 like
  • 2 in conversation