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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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