BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

I have the following data with the listed variables for time 1hr.  There are similar data sets for times 2,3,4,6,7,8,12,and 24 hrs.

    ID AMT Time CMT Y
15 1 0 1 3 0.40953 .
16 2 0 1 3 0.2531 .
17 3 0 1 3 30.549 .
18 4 0 1 3 2.2213 .
19 5 0 1 3 1.829 .
20 6 0 1 3 8.8514 .
21 7 0 1 3 29.094 .
22 8 0 1 3 4.2443 .
23 9 0 1 3 0.68437 .
24 10 0 1 3 3.3793 .
25 11 0 1 3 2.8721 .
26 12 0 1 3 0.7927 .
27 13 0 1 3 7.477 .
28 14 0 1 3 0.98951 .

 

I have done a box plot and ID's 7 and 3 are outliers.  My question is there code that I can use with  SAS univariate that will allow me to obtain the Winsorized mean variable Y for each collection time period?  I  have searched but could not find code modification to do so.  I realize this could be done by brute force by analyzing each time separately.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

1. Combine them into one data set and identify the source data set as the time.

 

data combined;
set time.time_hour: indsname=source; *assuming you have a naming convention;

dsin=source;
run;


2. Calculate summary statistics

proc univariate data=combined winsorized=5;
class dsin;
var y;
run;

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

So you have separate data sets for each time? Then combine the datasets into one, and perform PROC UNIVARIATE with a BY statement.

--
Paige Miller
jacksonan123
Lapis Lazuli | Level 10
This is my code but it says that it can't find Y but I did a proc contents
and Y was the variable name (see below).


Alphabetic List of Variables and Attributes


#

Variable

Type

Len

Format

Label


2

AMT

Num

8

BEST12.

AMT


4

CMT

Num

8

BEST12.

CMT


1

ID

Num

8

BEST12.

ID


6

NAMT

Num

8






3

TIME

Num

8

BEST12.

TIME


5

Y

Num

8

BEST12.

Y

This is my code:

ods exclude all;

proc univariate data=NORM2A winsorized=0.1;

ods output WinsorizedMeans=winMeans;

Var y;

by time;

run;

ods exclude none;




ballardw
Super User

Copy the code submitted and the messages from the log and paste that into a code box opened using the forum {I} icon.

 

You do know that exclude all means no output is generated with the example code so your Winmeans data set will not be created.

Reeza
Super User

1. Combine them into one data set and identify the source data set as the time.

 

data combined;
set time.time_hour: indsname=source; *assuming you have a naming convention;

dsin=source;
run;


2. Calculate summary statistics

proc univariate data=combined winsorized=5;
class dsin;
var y;
run;
jacksonan123
Lapis Lazuli | Level 10

This code solved my problem

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1197 views
  • 0 likes
  • 4 in conversation