BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Izzy
Calcite | Level 5

I am trying to write down the beg_srvc_date between '01jan2016'd and '01jun2017'd; but I keep getting error in my run data. Please advice. Service from 01/01/2016 to service date 06/01/2017. 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Let's use data that we all have access to. Is this what you are looking for? If not, please modify the DATA step:

 

data Subset;
set sashelp.snacks(rename=(Date=beg_srvc_date));
if '01jan2004'd < beg_srvc_date and beg_srvc_date < '01jun2004'd then do;
   /* do something here */
   foundDate = 1;
end;
else do;
   /* do something else here */
   foundDate = 0;
end;
run;

proc freq data=Subset;
tables foundDate;
run;

View solution in original post

13 REPLIES 13
PeterClemmensen
Tourmaline | Level 20

Please provide some of the code that you are using and preferably some sample data 🙂

Izzy
Calcite | Level 5

and beg_srvc_date between "01jan2016"d and "01jun2017"d;

art297
Opal | Level 21

You can only use between in a where statement. If you are trying to use it in an IF statement try:

and  "01jan2016"d<=beg_srvc_date<="01jun2017"d;

Art, CEO, AnalystFinder.com

 

Izzy
Calcite | Level 5

I have tried to eneter

and  "01jan2016"d<=beg_srvc_date<="01jun2017"d;

and it's still showing error. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post your code, some sample test data (in the form of a datastep), the log of that part etc.  It is pointless us trying to guess everything from the non information you have provided.  I mean does it run at all, is there errors/warnings, is beg_svc actually a date value or character?  Is it in the current query etc.  We need information to be able to tell you anything!

Izzy
Calcite | Level 5

and beg_srvc_date between "01jan2016"d and "01jun2017"d;
quit;

This is what I wrote and it is showing error message 

PeterClemmensen
Tourmaline | Level 20

And what error message is printet in the log?

Izzy
Calcite | Level 5

Error: The following columns were not found in the contributing tables: beg_srvce_date;

and  "01jan2016"d<=beg_srvc_date<="01jun2017"d;

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Thats because beg_srvce_date is not in the contributing dataset, nor is it actually shown in the tiny little code snippet you have provided.  Again, you need to provide all the information for us to be able to help you, we cannot see you machine, nor guess what you are doing.

art297
Opal | Level 21

Is it beg_srvce_date or beg_srvc_date?

 

Art, CEO, AnalystFinder.com

 

ballardw
Super User

@Izzy wrote:

and beg_srvc_date between "01jan2016"d and "01jun2017"d;
quit;

This is what I wrote and it is showing error message 


Post the code with error messages from the log. You are not providing sufficient information to answer your question without that detail.

Copy from your LOG, Open a code box on the forum using the menu icon {i} to preserve the format of the error message(s) otherwise the forum window may reformat the text moving critical indicators and paste into the code box.

Rick_SAS
SAS Super FREQ

Let's use data that we all have access to. Is this what you are looking for? If not, please modify the DATA step:

 

data Subset;
set sashelp.snacks(rename=(Date=beg_srvc_date));
if '01jan2004'd < beg_srvc_date and beg_srvc_date < '01jun2004'd then do;
   /* do something here */
   foundDate = 1;
end;
else do;
   /* do something else here */
   foundDate = 0;
end;
run;

proc freq data=Subset;
tables foundDate;
run;
Izzy
Calcite | Level 5

Thank you Rick and everyone else for their contribution. I will make the changes and adjustments to the data. 

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
  • 13 replies
  • 1232 views
  • 2 likes
  • 6 in conversation