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

Hello experts,

 

I am trying to get rid of values of 0 for the variable I am running PROC MEANS on. 

You'll notice that, after deleting salary data with observations of 0, I still had very low values that are close to 0.

 

GENDER	Method	N	Mean	Std Dev	Std Err	Minimum	Maximum
FEMALE	 	        528  873.5	327.3	14.2444	0.00100	 2000.0
MALE	 	      1315 824.4	429.1	3.7423	0	 8100.0
Diff (1-2)	Pooled	 	49.0313	425.7	18.8933	 	 
Diff (1-2)	Satterthwaite	49.0313	 	         14.7278

 @Reeza suggested that I use the ROUND function to eliminate these values, but I am having trouble piecing the code together. Here's my attempt so far:

 

*round really small numbers to  zero;
data practice.CompuStat_Execucomp3;
	set practice.CompuStat_Execucomp2;
	ROUND (SALARY <0> );
run; 

and the log:

 

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 70         
 71         *round really small numbers to  zero;
 72         data practice.CompuStat_Execucomp3;
 73         set practice.CompuStat_Execucomp2;
 74         ROUND (SALARY <0> );
                               _
                               390
                               76
 ERROR: Undeclared array referenced: ROUND.
 ERROR 390-185: Expecting an relational or arithmetic operator.
 
 ERROR 76-322: Syntax error, statement will be ignored.
 
 75         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set PRACTICE.COMPUSTAT_EXECUCOMP3 may be incomplete.  When this step was stopped there were 0 observations and 
          107 variables.
 WARNING: Data set PRACTICE.COMPUSTAT_EXECUCOMP3 was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              2296.37k
       OS Memory           35772.00k
       Timestamp           05/05/2018 02:51:07 PM
       Step Count                        62  Switch Count  0
       Page Faults                       0
       Page Reclaims                     323
       Page Swaps                        0
       Voluntary Context Switches        34
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 76         
 77         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 89         
 User: apmorabito0

If you have any suggestion please let me know. Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You just have a syntax error.  What you typed doesn't look like code for SAS or any other language.

ROUND (SALARY <0> )

The function call does not look like a function call. Plus you need to use the function in a valid place. Like an assignment statement.

 

The ROUND() function takes two arguments. The value to be rounded and the level of rounding.  So if you want to round to the hundredths place you would use round(sample,0.01).

 

salary = round(salary,0.01);

 

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

You just have a syntax error.  What you typed doesn't look like code for SAS or any other language.

ROUND (SALARY <0> )

The function call does not look like a function call. Plus you need to use the function in a valid place. Like an assignment statement.

 

The ROUND() function takes two arguments. The value to be rounded and the level of rounding.  So if you want to round to the hundredths place you would use round(sample,0.01).

 

salary = round(salary,0.01);

 

sastuck
Pyrite | Level 9

@Tom, thanks for that. My results are still showing a minimum of 0. Do you know why this would be?

 

*round really small numbers to  zero;
data practice.CompuStat_Execucomp3;
	set practice.CompuStat_Execucomp2;
	salary = round(salary,0.01);
run; 

*remove zeros;
data practice.CompuStat_Execucomp3;
	set practice.CompuStat_Execucomp3; 
	if salary=. then delete;
run;

title "Table 6. Difference in Means";
title2 "Male and Female CEOs";
proc ttest data=practice.CompuStat_Execucomp3;
class gender;
   var salary;
run;
Tom
Super User Tom
Super User

Is that a trick question? The minimum is zero because the lowest value is zero.

 

What do you want to do to remove the zeros?

The ROUND() with precision of 0.01 will convert values below 0.005 to zero.  It won't remove them.

How do you want to remove the zeros?  Do you want to delete the observation?

if 0=abs(round(salary,0.01)) then delete;

Do you want to change them to missing?

if 0=abs(round(salary,0.01)) then call missing(salary);

 

sastuck
Pyrite | Level 9

@ballardw pointed out that it is unlikely that a CEO would take a salary of 0, and so these (probably missing values) would unjustifiably be underestimating the mean for salary. For that reason, I think it makes most sense to just delete the observations with values for salary of 0.

Reeza
Super User

It’s been a fad lately to see CEO taking 0 salary, but it’s actually correct. Their renumeration is in stock shares or as a percent of profits instead. 

sastuck
Pyrite | Level 9

Interestingly, the mean for men is still 0.0600 . So odd . . . maybe I should dig around in the code book so see how these are coded? This is in thousands of dollars, so that would be an annual salary of $60 . . .

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 1497 views
  • 1 like
  • 3 in conversation