Urgent Please

Reply
Occasional Contributor
Posts: 6

Urgent Please

I am new to SAS so i would really appreciate your support.

 

I have to find the difference between the start date and the end date as a mismatch. But i think i missed something.

 

PROC SQL;

CREATE TABLE Mismatch AS

SELECT DISTINCT START_DATE as START_DATE, END_DATE as END_DATE

FROM File_1;

where Mismatch=intck("YEAR",START_DATE,END_DATE),

if Mismatch1 <= 0.5,"Less than six months"

do;

else

IF(AND(Mismatch>0.5,Mismatch<=1),"Over six months & less than one Year"

QUIT;

Super User
Posts: 5,380

Re: Urgent Please

First, use a title to your post that describes your problem.

Second, this is not a support, it's implicit that everyone that post stuff here is looking for help, so don't strive for a higher priority than any other community member.

 

You are mixing SQL and data step syntax, you'll get an error when running this, right?

Go back to the SQL guides and look for the case statement.

Data never sleeps
Occasional Contributor
Posts: 6

Difference bewteen start and end date

 So if i change this to

 

PROC SQL;

CREATE TABLE Mismatch AS

SELECT DISTINCT START_DATE as START_DATE, END_DATE as END_DATE

FROM File_1;

where Mismatch=intck("YEAR",START_DATE,END_DATE),

 

QUIT;

 

But still it appears as .

Trusted Advisor
Posts: 1,137

Re: Difference bewteen start and end date

Please try

 

PROC SQL;
CREATE TABLE Mismatch AS
SELECT DISTINCT *, intck("YEAR",START_DATE,END_DATE) as Mismatch , case when intck("YEAR",START_DATE,END_DATE)<=0.5 then "Less than six months", 
when 0.5 < intck("YEAR",START_DATE,END_DATE) <= 1 then "Over six months & less than one Year" else '' end as Mismatch1 from 
File_1;
QUIT;
Thanks,
Jag
Occasional Contributor
Posts: 6

Re: Difference bewteen start and end date

Thank you for your reply. I received below error

 

_

22

200

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =,

>, >=, ?, AND, BETWEEN, CONTAINS, ELSE, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,

LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, WHEN, ^, ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.

 

Occasional Contributor
Posts: 6

Re: Difference bewteen start and end date

Thank you for your help. Unfortunatley i received below error

 

_

22

200

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =,

>, >=, ?, AND, BETWEEN, CONTAINS, ELSE, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,

LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, WHEN, ^, ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.

 

Occasional Contributor
Posts: 6

Re: Difference bewteen start and end date

Thank you for your help. Unfortunatley i received below error. I think i have to change the date format but i looked every where and i do not know how?
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =,
>, >=, ?, AND, BETWEEN, CONTAINS, ELSE, END, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE,
LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, WHEN, ^, ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.
Trusted Advisor
Posts: 1,137

Re: Difference bewteen start and end date

[ Edited ]

Hi Justin,

 

Sorry the code i provided had a syntax error where an extra comma was included , i remove that comma now.

 

Please try the below tested code

 

PROC SQL;
CREATE TABLE Mismatch AS
SELECT DISTINCT *, intck("YEAR",START_DATE,END_DATE) as Mismatch , case when intck("YEAR",START_DATE,END_DATE)<=0.5 then "Less than six months" 
when 0.5 < intck("YEAR",START_DATE,END_DATE) <= 1 then "Over six months & less than one Year" else '' end as Mismatch1 from 
File_1;
QUIT;

Thanks,

Jag

Thanks,
Jag
Trusted Advisor
Posts: 1,137

Re: Difference bewteen start and end date

Hi Justin,

Hope you tried this code.

Could you please let me know if it helped you.

Thanks,
jag
Thanks,
Jag
Occasional Contributor
Posts: 6

Re: Difference bewteen start and end date

Hi Jag

Thank you so much for your help. But still it is giving me error. I do not know why my replies don't appear??
Super User
Posts: 5,380

Re: Difference bewteen start and end date

No, that still gives you a syntax error. Please post code that you are actual using, or even better, the log.

Since it seems that you are mixing the basic concepts of filtering and conditional processing, I think taking some SAS programming/SQL training would be beneficial for you.

 

Also, what are you trying to achieve?

I think you can't get half years using this syntax. Are you looking for full calendar half years (try "YEAR2"), or 182/183 days interval?

 

Data never sleeps
Super User
Posts: 11,104

Re: Urgent Please

You also want to be sure that your date variables as SAS date valued variables. Run proc contents on your data set and ensure that your date variables report as numeric with format and/or informat that have a date appearance such as MMDDYY10. Also you want to make sure that your dates are dates and do not have time component as you may get a variety of unexpected results.

Ask a Question
Discussion stats
  • 11 replies
  • 451 views
  • 1 like
  • 4 in conversation