DATA Step, Macro, Functions and more

Using Drop contionally

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Using Drop contionally

Hello All,

 

I want to combine 2 data sets as below and i am not sure how to use both where and Drop functions together for data set history.adm_ytd_pivot_2017.

It would be great help if you can assist me with this.

data adm_en4;
set adm_en3 history.adm_2017(where=( commence_year = '2017'));
run;

 


Accepted Solutions
Solution
4 weeks ago
Super User
Posts: 10,214

Re: Using Drop conditionally


@BIDD wrote:

Hello All,

 

I want to combine 2 data sets as below and i am not sure how to use both where and Drop functions together for data set history.adm_ytd_pivot_2017.

It would be great help if you can assist me with this.

data adm_en4;
set adm_en3 history.adm_2017(where=( commence_year = '2017'));
run;

 


Just add the drop dataset options:

data adm_en4;
set
  adm_en3
  history.adm_2017 (
    drop=variables you want to drop
    where=(commence_year = '2017')
  )
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Respected Advisor
Posts: 4,736

Re: Using Drop contionally

If you want the where clause applied to all source data sets then you can write your code as below:

data adm_en4;
  set adm_en3 history.adm_2017;
  where commence_year = '2017';
run;

The way you've done it will only apply the where clause for the data set which goes with the where clause.

Contributor
Posts: 27

Re: Using Drop contionally

Hi,

i want to use Where  and drop clause only for history.adm_2017, no changes in adm_en3 data.

Super User
Super User
Posts: 9,599

Re: Using Drop contionally

Then put them on the set part as you have done:

data adm_en4;
  set adm_en3 history.adm_2017(where=( commence_year = '2017') drop=...);
run;
Contributor
Posts: 27

Re: Using Drop contionally

Hi, thanks for the advice...it worked.
Solution
4 weeks ago
Super User
Posts: 10,214

Re: Using Drop conditionally


@BIDD wrote:

Hello All,

 

I want to combine 2 data sets as below and i am not sure how to use both where and Drop functions together for data set history.adm_ytd_pivot_2017.

It would be great help if you can assist me with this.

data adm_en4;
set adm_en3 history.adm_2017(where=( commence_year = '2017'));
run;

 


Just add the drop dataset options:

data adm_en4;
set
  adm_en3
  history.adm_2017 (
    drop=variables you want to drop
    where=(commence_year = '2017')
  )
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 27

Re: Using Drop conditionally

Posted in reply to KurtBremser

Hi, thanks for the advice...it worked.

☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 84 views
  • 0 likes
  • 4 in conversation