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

Hi SAS Instructor,

 

Today I went through a question 1.07 in Programming 2. The question and answer are as below

ResoluteCarbon_0-1617341000139.png

First, to me, it is not the easiest way, and there is no way for us to judge if it is the easiest one, for me, I can do by setting the option drop right at the set statement ( it is easier because I do not need to create a new data statement for drop.

Secondly, if I were the instructors, I would changed the question to :how to drop the EndDate in three implicitly output datasets but this available is still calculable (that is when we can use the data statement drop EndDate; ) or how to drop......and this variable is non-calculable during the datatstep (at that time we set an option drop right at the set statement).

 

Please let me know if I fall into any fallacy.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

Since we are being asked how to most easiest way to drop from three tables in a data step, we will consider the following three methods.
1st. Use the drop= dataset option in the data statement.
2nd. Use the drop= dataset option in a set statement.
3rd. Use the drop statement.


Of these, 2nd is not suitable because it will not be able to calculate the EndDate - StartDate.
1st. and 3rd. are almost the same, but with drop= dataset option, you need to write three, whereas with the drop statement, you only need to write one, so the answer is the drop statement.

 

I think it is clear question.

View solution in original post

3 REPLIES 3
japelin
Rhodochrosite | Level 12

Since we are being asked how to most easiest way to drop from three tables in a data step, we will consider the following three methods.
1st. Use the drop= dataset option in the data statement.
2nd. Use the drop= dataset option in a set statement.
3rd. Use the drop statement.


Of these, 2nd is not suitable because it will not be able to calculate the EndDate - StartDate.
1st. and 3rd. are almost the same, but with drop= dataset option, you need to write three, whereas with the drop statement, you only need to write one, so the answer is the drop statement.

 

I think it is clear question.

Shmuel
Garnet | Level 18

In this case you can't drop ENDDATE from input because you need it to calculate StormLength.

 

If you use DROP statement it relates to all output data sets, and you need not enter the DROP option for each output data set.

 

ballardw
Super User

If your source data is not clean you may have to use a dataset option to drop one or more variables because they are of a different type in some data sets.

data junk1;
   x='1234';
   y=42;
run;
data junk2;
  x=123;
  y= 56;
run;

/* this fails because X is both numeric and character*/
data combined;
   set junk1
       junk2
   ;
   drop x;
run;
/* this works because only one type of x makes it into
   the data vector
*/
data combined2;
   set junk1 (drop=x)
       junk2
   ;
   drop x;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 959 views
  • 4 likes
  • 4 in conversation