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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

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

1 REPLY 1
stat_sas
Ammonite | Level 13

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1681 views
  • 0 likes
  • 2 in conversation