BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

Do you know please, how to write the proc sql count distinct statement with condition to have this output :

 

Input :

SASdevAnneMarie_0-1669730872392.png

Output :

SASdevAnneMarie_1-1669730889202.png

Thank you !

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc sql;
    create table want as select count(*) from have group by week,data;
quit;

 

If you want tested code, please provide the data as text as SAS data step code (instructions) and not as screen captures.

 

You can also do this via PROC FREQ

 

proc freq data=have;
    tables week*data/nocol norow nopercent;
run;
--
Paige Miller
Kurt_Bremser
Super User

Please do never (as in NEVER) supply example data in pictures. Always (as in ALWAYS) use a data step with datalines, posted in a code box.

Because of the lack of usable data, this code is untested:

proc report data=have;
column week n,data;
define week / group;
define data / "" across;
define n / "";
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 292 views
  • 2 likes
  • 3 in conversation