Help using Base SAS procedures

proc univariate, output columns to existing database

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

proc univariate, output columns to existing database

proc univariate data=existing;

var a b c;

output out=existing sum=Asum Bsum Csum N=Act Bct Cct;

run;

I already have an existing dataset with 10 variables. I want to add the additional 6 variables from the proc univariate procedure but when I use the output statement, it overwrites all the existing variables instead of adding additional columns.

How can I make so it so that the outputs I want (sum and N) are added to an existing dataset?

Thank you very much.


Accepted Solutions
Solution
‎08-14-2014 12:33 PM
Trusted Advisor
Posts: 1,228

Re: proc univariate, output columns to existing database

Hi,

Your syntax will replace your existing dataset with calculated summary stats. To add stats in your original data set save stats to another dataset (want) and merge back to original one to get desired dataset (final).

proc univariate data=existing;

var a b c;

output out=want sum=Asum Bsum Csum N=Act Bct Cct;

run;

data final;

if _n_=1 then set want;

set have;

run;

View solution in original post


All Replies
Solution
‎08-14-2014 12:33 PM
Trusted Advisor
Posts: 1,228

Re: proc univariate, output columns to existing database

Hi,

Your syntax will replace your existing dataset with calculated summary stats. To add stats in your original data set save stats to another dataset (want) and merge back to original one to get desired dataset (final).

proc univariate data=existing;

var a b c;

output out=want sum=Asum Bsum Csum N=Act Bct Cct;

run;

data final;

if _n_=1 then set want;

set have;

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 520 views
  • 0 likes
  • 2 in conversation