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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2094 views
  • 2 likes
  • 3 in conversation