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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.