BookmarkSubscribeRSS Feed
SAS_user_n
Calcite | Level 5
I want to add one more observation to the exisiting SAS dataset and could not find a good resolution ....

I have two variables called X,Y with 1000 observations each.

X represents categories (ranging from 0 to 1000 but numbers themselves have no meaning), and Y represents each category's score.

I want to add a 1001st row for X that denotes a category that does not appear between 0 and 1000, and assign it the value of sample average of 1000 Y values.

So the 1001st row will have: X = 9999, Y=sample average of Y's
Thank you!
2 REPLIES 2
ArtC
Rhodochrosite | Level 12
There are multiple ways to do this. With your small data sets, a variation of the following should work for you.
[pre]proc summary data=sashelp.class;
var height;
output out=sumry mean=height;
run;

data extra(keep=name height);
set sashelp.class(keep=height name) end=eof;
output extra;
if eof then do;
name='Xxxxx';
set sumry;
output extra;
end;
run;[/pre]

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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