BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aminkarimid
Lapis Lazuli | Level 10

Hello everybody.

I have variables which its attributs are showed below:

 

Alphabetic List of Variables and Attributes
# Variable      Type      Len       Format       Informat            Label
TRD_EVENT_DTNum8DATE9.DATE9.TRD_EVENT_DT
TRD_EVENT_MSChar1$1.$1.TRD_EVENT_MS
TRD_EVENT_TMChar8$8.$8.TRD_EVENT_TM
TRD_INSTR_NAMEChar9$9.$9.TRD_INSTR_NAME
TRD_PRChar5$5.$5.TRD_PR
TRD_STCK_CDChar5$5.$5.TRD_STCK_CD
TRD_STCK_GRP_ID_CDChar2$2.$2.TRD_STCK_GRP_ID_CD
TRD_STCK_IDChar12$12.$12.TRD_STCK_ID
TRD_TRA_NRChar10$10.$10.TRD_TRA_NR
TRD_TUROVRChar9$9.$9.TRD_TUROVR

 

Explanation of variables of some columns:

[TRD_EVENT_DT] Month / Day / Year
,[TRD_EVENT_TM] Time: hh:mm:ss
,[TRD_PR] Stock Price
,[TRD_TUROVR] Turnover.

 

I want to create filter on the data source in a specific time range. The time variable is between 9:00 till ~16:00. However, I just want to limit data set between 9:00 till 12:00.

How can I do that?

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Since your time variable is shown as char8, I'd try:

 

data want;
  set have;
  if '09:00't le input(TRD_EVENT_TM,time8.) le '12:00't;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

Since your time variable is shown as char8, I'd try:

 

data want;
  set have;
  if '09:00't le input(TRD_EVENT_TM,time8.) le '12:00't;
run;

Art, CEO, AnalystFinder.com

 

Reeza
Super User

Why haven't you changed the type/format to a date/datetime rather than character?

A lot of your questions could be answered very simply if you specified them as time/date/datetime variables. 

 

where hour(time_variable) between 9 and 12;

 

http://support.sas.com/resources/papers/proceedings10/134-2010.pdf

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2491 views
  • 2 likes
  • 3 in conversation