BookmarkSubscribeRSS Feed
RPYee
Quartz | Level 8

I have two types of events (Event_A , Event_B) and their associated timestamps.  There can be multiple timestamps for the same event.  I want to check the event for each row and create a computed field related to the timestamp field.  My "CASE" statement was originally:

 

CASE

WHEN event = EVENT_A

THEN timestamp

ELSE ' '

END

 

This would give me an error that the second datatype doesn't match the first.  So, I changed it to:

CASE

WHEN event = EVENT_A

THEN timestamp

END

 

This works fine, but it puts a period when the test is false.  Is there a way to just leave the result blank?  I'll have two computed fields, EVENT_A_TMPSTP and EVENT_B_TMSTP.  I'll then find the minimum of each occurrence and move forward with those results.  I'm not sure how the period will play into this next step...

Thanks for any help!!

RPYee

 

___________________________________
The fact that I ask for help simply means I am inexperienced and under-educated. Please don't assume I am incompetent and uneducated.
2 REPLIES 2
Tom
Super User Tom
Super User

You cannot store a character string, like a space, into a numeric variable.

But you can change the way numeric missing values are printed by using the MISSING option.

Example:

data test;
  row=1;
  now=datetime();
  format now datetime19.;
  output;
  row=2;
  now=.;
  output;
run;

proc print data=test;
run;

options missing=' ';
proc print data=test;
run;

image.png

PaigeMiller
Diamond | Level 26

I'll have two computed fields, EVENT_A_TMPSTP and EVENT_B_TMSTP.  I'll then find the minimum of each occurrence and move forward with those results.  I'm not sure how the period will play into this next step...

 

I'm not sure how the blank will play into this next step. But it would be better, in my mind, to leave the missing there because for all arithmetic and functions and boolean comparisons, we know exactly how SAS will handle the missing value. You can use the MIN function, for example, and this will return the minimum of the non-missing values.

 

min(event_a_tmpstp,event_b_tmstp)

So, when you are finding the minimum, and one of the two values is missing, what do YOU want as the result?

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1393 views
  • 0 likes
  • 3 in conversation