DATA Step, Macro, Functions and more

else if

Accepted Solution Solved
Reply
Super Contributor
Posts: 303
Accepted Solution

else if

What is wrong with this code?

 

Data Mite;

Input obs  time;

Cards;

      0   8

     1   14 

      0   17

      1   20

;

Run;

 

 

data MItest;

set MIte;

if obs=0 then ttime=.; else ttime=time;

run;


Accepted Solutions
Solution
‎04-27-2016 03:54 PM
Super User
Posts: 19,772

Re: else if

Posted in reply to desireatem

Nothings wrong, it runs without error. 

Why do you think something is wrong?

 

Remember we can't read your mind Smiley Wink

So if something unexpected is happening you need to explain what you expect and what isn't happening. Given what you've provided I have no idea what you want. 

 

1    Data Mite;
2    Input obs  time;
3    Cards;

NOTE: The data set WORK.MITE has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.18 seconds
      cpu time            0.01 seconds


8    ;
9    Run;

10   data MItest;
11   set MIte;
12   if obs=0 then ttime=.; else ttime=time;
13   run;

NOTE: There were 4 observations read from the data set WORK.MITE.
NOTE: The data set WORK.MITEST has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

View solution in original post


All Replies
Solution
‎04-27-2016 03:54 PM
Super User
Posts: 19,772

Re: else if

Posted in reply to desireatem

Nothings wrong, it runs without error. 

Why do you think something is wrong?

 

Remember we can't read your mind Smiley Wink

So if something unexpected is happening you need to explain what you expect and what isn't happening. Given what you've provided I have no idea what you want. 

 

1    Data Mite;
2    Input obs  time;
3    Cards;

NOTE: The data set WORK.MITE has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.18 seconds
      cpu time            0.01 seconds


8    ;
9    Run;

10   data MItest;
11   set MIte;
12   if obs=0 then ttime=.; else ttime=time;
13   run;

NOTE: There were 4 observations read from the data set WORK.MITE.
NOTE: The data set WORK.MITEST has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
Super Contributor
Posts: 303

Re: else if

There was no error, I had the data set opened,that is why

Super User
Posts: 11,343

Re: else if

Posted in reply to desireatem

Sounds like you had an ERROR. Show the error from the Log and the code submitted that generated the error.

 

If you had posted something like

ERROR: You cannot open USER.JUNK.DATA for output access with member-level control because

USER.JUNK.DATA is in use by you in resource environment ViewTable Window.

 

we could likely have told you that you had the set or an explorer window about the contents open.

 

☑ This topic is solved.

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

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