Actually i am having two tables and check the counts of two datasets based on dates i am doing in this way but i ma getting
ERROR: Expression using equals (=) has components that are of different data types.
How can i check the counts
data l;
input id date date9.;
format date date9.;
cards;
2 13jan2012
2 13jan2012
2 13jan2012
run;
data l2;
input id date date9.;
format date date9.;
cards;
2 12jan2012
2 12jan2012
2 12jan2012
2 13jan2012
2 13jan2012
2 13jan2012
;
run;
proc sql;
select max(date) format=date9. into:maxdt from l2;
quit;
proc sql;
select count(*) into:S1 from l;
select count(*) into:s2 from l2 where date="&maxdt.";
quit;
ERROR: Expression using equals (=) has components that are of different data types.
You need this:
select count(*) into:s2 from l2 where date="&maxdt."d ;
Ksharp
You need this:
select count(*) into:s2 from l2 where date="&maxdt."d ;
Ksharp
Thqs Ksharp
i guess .(dot) after maxdt is not required.Not sure incase i am wrong
You are right. It doesn't matter whether the dot is there.
the same result will be .
Another approach, not as slick of course, is to remove 'format=' and convert the date variable into numeric digits.
proc sql;
select max(date) into:maxdt from l2;
quit;
proc sql;
select count(*) into:S1 from l;
select count(*) into:s2 from l2 where date=input("&maxdt.",20.);
quit;
Or keep the format and then use informat to convert:
proc sql;
select count(*) into:S1 from l;
select count(*) into:s2 from l2 where date=input("&maxdt.",date9.);
quit;
Haikuo
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.