I am reading a SAS data set in PROC SQL and using COUNT. It is giving me one extra count - I suspect it is counting the header as well. How do I fix this ?
Here's the code:
PROC SQL;
CREATE TABLE Nat_1 AS
SELECT DISTINCT Loc_Nat,
COUNT(MBR_ID) AS Other
FROM Employee4
WHERE Loc_Nat = 'National'
QUIT;
And how will we tell from that? Provide test data in the form of a datastep!
The sql looks wrong to me, you are using distinct, and counting with a where clause. Seems to be counter intuitive.
proc sql;
create table nat_1 as
select loc_nat,
count(mbr_id) as other
from employee4
group by loc_nt
having loc_nat="National";
quit;
Please post a sample of what you 'HAVE' and what your desired output 'WANT'
@VarunD wrote:
I am reading a SAS data set in PROC SQL and using COUNT. It is giving me one extra count - I suspect it is counting the header as well. How do I fix this ?
Here's the code:
PROC SQL;
CREATE TABLE Nat_1 AS
SELECT DISTINCT Loc_Nat,
COUNT(MBR_ID) AS Other
FROM Employee4
WHERE Loc_Nat = 'National'
QUIT;
The "header" would only get counted if you imported the header as a value for the variables.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.