DATA Step, Macro, Functions and more

How to view whole dataset after applying Where or If statement

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

How to view whole dataset after applying Where or If statement

Hello,

 

I want to know if I give any conditional arithmetic expression then can I view whole datasets?

 

Example - if I have List of employees with Department and Salary and I have to calculate incentives for specific department but I want to view whole data set and not only those specific employees.


Accepted Solutions
Solution
‎02-13-2018 11:20 AM
Super User
Posts: 13,898

Re: How to view whole dataset after applying Where or If statement

Do not apply a where or subsetting if statement if you want the other records. You would conditionally assign values.

 

data want;

   set have;

   if department = 'SALES' then incentive = salary* 0.1;

run;

would only add an incentive for the specific department. All the other records would have missing values for incentive.

 

 

View solution in original post


All Replies
Super User
Posts: 23,963

Re: How to view whole dataset after applying Where or If statement

WHERE or subsetting IF removes those records. Instead of WHERE/IF consider creating a flagged variable to identify the records instead.

 


rasika wrote:

Hello,

 

I want to know if I give any conditional arithmetic expression then can I view whole datasets?

 

Example - if I have List of employees with Department and Salary and I have to calculate incentives for specific department but I want to view whole data set and not only those specific employees.


 

Solution
‎02-13-2018 11:20 AM
Super User
Posts: 13,898

Re: How to view whole dataset after applying Where or If statement

Do not apply a where or subsetting if statement if you want the other records. You would conditionally assign values.

 

data want;

   set have;

   if department = 'SALES' then incentive = salary* 0.1;

run;

would only add an incentive for the specific department. All the other records would have missing values for incentive.

 

 

Occasional Contributor
Posts: 13

Re: How to view whole dataset after applying Where or If statement

Thanks a ton.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 102 views
  • 0 likes
  • 3 in conversation