BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I can't run this code, it takes a long time. I'm wondering if my code is right. Thank you.

DATA TBT; 
set TBM; 
     (where=((D_VALO>='31DEC2019:00:00:00'dt)
                and (D_VALO <='31DEC2020:00:00:00'dt)));
run; 
5 REPLIES 5
PaigeMiller
Diamond | Level 26

Can you show us a portion of the data set TBM, showing the variable D_VALO for a few records?

 

When you say it is taking too long, how big is the data set?

 

What happens if you change the code to this:

 

DATA TBT; 
set TBM /* Note I removed a semicolon here */
     (where=((D_VALO>='31DEC2019:00:00:00'dt)
                and (D_VALO <='31DEC2020:00:00:00'dt)));
run; 

 

--
Paige Miller
ballardw
Super User

Try picking one of these:

DATA TBT; 
/* where as a DATASET OPTION*/
set TBM  (where=((D_VALO>='31DEC2019:00:00:00'dt)
                and (D_VALO <='31DEC2020:00:00:00'dt)));
run; 

or

DATA TBT; 
set TBM; 
/* Where statement*/
 where  (D_VALO>='31DEC2019:00:00:00'dt)
                and (D_VALO <='31DEC2020:00:00:00'dt);
run; 

It shouldn't make much difference in run time by you can use a single comparison like

'31DEC2019:00:00:00'dt <=  D_VALO  <= '31DEC2020:00:00:00'dt

Which is at least a little easier to type and see the logic involved.

 

How many records are in the TBM data set and how long is "too long"?

 

SASdevAnneMarie
Barite | Level 11
Thank you, the problem is that my data is very huge.
I'm wondering if there is another way to write the data step. When I'm using this code my programm is running the hours 😞 Thank you !
LinusH
Tourmaline | Level 20

We need much more info tu understand/help.

Were is your data located?

Looks like in your saswork, but is that on your local computer or remote (what specs does your PC/server have).

How large is the source data set?

Please provide a log with options FULLSTIMER and MSGLEVEL=I set.

Data never sleeps
maguiremq
SAS Super FREQ

One issue is your semi-colon placement on the SET statement. Your WHERE condition should be applied to the SET statement.

DATA TBT; 
set TBM (where=((D_VALO>='31DEC2019:00:00:00'dt)
                and (D_VALO <='31DEC2020:00:00:00'dt)));
run; 

Alternatively, you could do this:

DATA TBT; 
set TBM; 
where D_VALO>='31DEC2019:00:00:00'dt and D_VALO <='31DEC2020:00:00:00'dt;
run; 

I don't really work with date literals like this, let alone date-time literals. Nor can I know if this works without some example data. If possible, post some reproducible code or data in a DATALINES statement.

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!

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
  • 5 replies
  • 552 views
  • 4 likes
  • 5 in conversation