Hi,
I have a big table with lots of observations and i want to manipulate/transform my data. Here is my problem:
PROC SQL;
CREATE TABLE WORK.Lista AS
SELECT t1.Name,
t1.ID,
t1.Description,
/* Calculation Number */
(case when t1.Description EQ 'PROT' then FREQ(t1.Description)
end) AS Number
FROM WORK.TOTAL t1
GROUP BY t1.ID
ORDER BY t1.Name ASC;
QUIT;
I do not want to have a report of "proc freq". The idea is make a new query with a new variable(Number) and continue the program.
I want count only when Description = 'PROT' and not when is different. It is dificult to find the arguments of function freq. What i have to do is to call freq with a condition inside the function, and not outside(that's happen now). But the new collumn(Number) must appear in all observations, also when observation with t1.Description NE 'PROT' must have the count of all 'PROT'
Regards,
Aleixo
SELECT t1.Name, t1.ID,
count(t1.description) AS Number
FROM WORK.TOTAL t1
where t1.description eq 'PROT'
GROUP BY t1.ID
SELECT t1.Name, t1.ID,
count(t1.description) AS Number
FROM WORK.TOTAL t1
where t1.description eq 'PROT'
GROUP BY t1.ID
Very nice. Works very well.
I have to use more times the statement 'where' in that location of proc sql
thanks a lot
And thanks other answers xD
why don't you use the function count() instead of freq??
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.