BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aleixo
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
SELECT t1.Name, t1.ID, 
          count(t1.description) AS Number
      FROM WORK.TOTAL t1 
      where t1.description eq 'PROT'
      GROUP BY t1.ID
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26
SELECT t1.Name, t1.ID, 
          count(t1.description) AS Number
      FROM WORK.TOTAL t1 
      where t1.description eq 'PROT'
      GROUP BY t1.ID
--
Paige Miller
Aleixo
Quartz | Level 8

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

 

SASUser_22
Calcite | Level 5

why don't you use the function count() instead of freq?? 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 771 views
  • 0 likes
  • 3 in conversation