BookmarkSubscribeRSS Feed
rtniblett15
Calcite | Level 5

I have a lengthy question for you SAS experts.

I am conducting an experiment using an electronic sow feeder, where animals are allowed to visit a feeder multiple times per day, thus presenting a final dataset with many visits per day for each animal. Each time feed is dispensed, if there is an allotment left, a bodyweight is recorded. I have predicted weight values based on two real weights (beginning of test and end of test) and want to remove outliers based on a +/- 5% window of this predicted weight. The weights are predicted for each day of test for each animal. I would assume that is a many to one comparison. With the same dataset, I want to sum the feed intake for each animal by day. There is more to the story, but this is where I want to start. I have attached a portion of the dataset that I am working with.

 

Obs desc entry exit location GiltID RFID Trt Duration Feed1 Feed2 Wt Controller Station FV NFV entry2 exit2 feed entrydate1234567891011121314
Gestation01JAN60:12:26:4501JAN60:12:26:4512209109.85E14AD8732.0000.000198.414121001SEP22:10:33:3601SEP22:10:48:002.00001SEP2022
Gestation01JAN60:12:26:4601JAN60:12:26:4612209109.85E14AD90.1830.0000.000121001SEP22:18:00:0001SEP22:18:00:000.18301SEP2022
Gestation01JAN60:12:26:4601JAN60:12:26:4612209109.85E14AD12302.8150.000202.382121001SEP22:18:43:1201SEP22:19:12:002.81501SEP2022
Gestation01JAN60:12:26:4601JAN60:12:26:4612209109.85E14AD1370.0000.0000.000120101SEP22:20:52:4801SEP22:20:52:480.00001SEP2022
Gestation01JAN60:12:26:4601JAN60:12:26:4612209109.85E14AD17743.9990.000208.776121002SEP22:06:28:4802SEP22:06:57:363.99902SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD370.0000.0000.000120102SEP22:18:43:1202SEP22:18:43:120.00002SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD510.0000.0000.000120102SEP22:19:12:0002SEP22:19:12:000.00002SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD1430.0000.0000.000120102SEP22:19:55:1202SEP22:19:55:120.00002SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD20.0000.0000.000120102SEP22:20:09:3602SEP22:20:09:360.00002SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD2150.3660.000210.539121003SEP22:04:19:1203SEP22:04:33:360.36603SEP2022
Gestation01JAN60:12:26:4701JAN60:12:26:4712209109.85E14AD21833.6330.000209.217121003SEP22:10:04:4803SEP22:10:33:363.63303SEP2022
Gestation01JAN60:12:26:4801JAN60:12:26:4812209109.85E14AD300.0000.0000.000120103SEP22:15:21:3603SEP22:15:21:360.00003SEP2022
Gestation01JAN60:12:26:4801JAN60:12:26:4812209109.85E14AD1020.0000.0000.000120103SEP22:18:14:2403SEP22:18:14:240.00003SEP2022
Gestation01JAN60:12:26:4801JAN60:12:26:4812209109.85E14AD200.0000.0000.000120103SEP22:18:28:4803SEP22:18:28:480.000

03SEP2022

 

The predicted values for this animal would be as follows:

D0220910231219.45242.55
D1220910233.0952221.4405244.75
D2220910235.1905223.431246.95
D3220910237.2857225.4214249.15

 

I had another dataset with a day of test column, but it is not shown here. The columns in the predicted weight table are day, visualid, -5%, PW, +5%. I am not sure if this is possible, but I can only assume the code is more advanced than my current skill level. Some of my requests can be done in a pivot table in excel, but not the outlier removal without formulation.

1 REPLY 1
ballardw
Super User

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

Only need to show enough records to allow us to perform the actions you need.

 

Since your "predicted" values have no column headings or description any match with the other data is going to rely on a lot of guessing. You should also provide that data in the forum of a data step. Then identify which variables in the "predicted" data are to be used to match the collected data. I don't see a D0 in the collected data so you need to describe how that relates to the collected data.

 

In this case, you need to provide details as to which variables are used for what. You seem to have potentially 7 columns at least that might be used to identify groups but I am not sure which ones you intend or how.

Note that typically using a correct format for a date, time or datetime variable in a procedure like Means or Summary will allow you to group by that

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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