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.
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;
Please provide some of the code that you are using and preferably some sample data 🙂
and beg_srvc_date between "01jan2016"d and "01jun2017"d;
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
I have tried to eneter
and "01jan2016"d<=beg_srvc_date<="01jun2017"d;
and it's still showing error.
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!
and beg_srvc_date between "01jan2016"d and "01jun2017"d;
quit;
This is what I wrote and it is showing error message
And what error message is printet in the log?
Error: The following columns were not found in the contributing tables: beg_srvce_date;
and "01jan2016"d<=beg_srvc_date<="01jun2017"d;
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.
Is it beg_srvce_date or beg_srvc_date?
Art, CEO, AnalystFinder.com
@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.
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;
Thank you Rick and everyone else for their contribution. I will make the changes and adjustments to the data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.