DATA Step, Macro, Functions and more

Drop statement for dropping list of variables.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Drop statement for dropping list of variables.

Got stuck with a problem related to Drop statement.attached herewith the problem and its 4 options.

Please help me to find 1.

Thanks


Accepted Solutions
Solution
2 weeks ago
Super User
Super User
Posts: 6,502

Re: Drop statement for dropping list of variables.

The question specifically asked for how to specify the drop using dataset options. 

 

image.png

View solution in original post


All Replies
Super User
Posts: 17,840

Re: Drop statement for dropping list of variables.

Post your questions directly into the forum, not as attachments. Many users will not download attachments. 

Trusted Advisor
Posts: 1,384

Re: Drop statement for dropping list of variables.

There are two ways to use DROP statement:

 

1)  data wnat(DROP=var1 var2 ...);  /* with the equal sign */

       set have;

           ... any code ...

     run;

 

2)  data want;

       set have;

          ... any code ...

         DROP var1 var2 ...;        /* without the equal sign */

    run;

Super User
Super User
Posts: 6,502

Re: Drop statement for dropping list of variables.

Let's look at the choices.

image.png

B anc C are wrong because they have commas.

B and D are wrong because they dont have the equal sign that all dataset options require.

So A is the best answer.

 

But all four are wrong because the parenthesis themselves are not part of the DROP= dataset option.  If you have other dataset options, like LABEL= or RENAME= they would all be nested inside the single set of () following the dataset name.

Occasional Contributor
Posts: 6

Re: Drop statement for dropping list of variables.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hello Tom

But if we look at the given code its doesnt seem like a drop dataset option .

It looks like a statement so should it be the option D but ofcourse as you said without the () brackets. 

Solution
2 weeks ago
Super User
Super User
Posts: 6,502

Re: Drop statement for dropping list of variables.

The question specifically asked for how to specify the drop using dataset options. 

 

image.png

Occasional Contributor
Posts: 6

Re: Drop statement for dropping list of variables.

oops sorry ...You are right ......
Super User
Posts: 17,840

Re: Drop statement for dropping list of variables.


rajvir wrote:

 

 

Hello Tom

But if we look at the given code its doesnt seem like a drop dataset option .

It looks like a statement so should it be the option D but ofcourse as you said without the () brackets. 


A good rule of thumb if you're not certain about something is to check the documentation. You may not always understand exactly what it's saying, but the examples will often help with that. Reading through the examples may help with your understanding of the DROP dataset option, versus the DROP statement.

 

DROP, data step option

https://support.sas.com/documentation/cdl/en/ledsoptsref/69751/HTML/default/viewer.htm#n15goor3q758g...

 

DROP, statement

http://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#n1capr0s7tilbvn...

 

Documentation examples/explanations:

http://support.sas.com/documentation/cdl/en/basess/68381/HTML/default/viewer.htm#p10jjd7e6qn396n1a22...

☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 132 views
  • 3 likes
  • 4 in conversation