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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 412 views
  • 2 likes
  • 3 in conversation