BookmarkSubscribeRSS Feed
WilliamB
Obsidian | Level 7

Hello,

I would like to select the largest week per month and divide QCNUM / QCDEN into percentages.

 

In SQL preferably.

 

Thanks for your help

 

Table      
      
COMOISCOSEMCOESVDQCNUMQCDEN 
20200120200437541294824086 
20200120200237541295124088 
20200120200537541295024088 
20200120200337541295024076 
20200120200137541288624079 
20200220200737541292324147 
20200220200637541295624152 
20200220200837541286224149 
      
      
Want      
COMOISCOSEMCOESVDQCNUMQCDENtaux
2020012020053754129502408854%
2020022020083754128622414953%
3 REPLIES 3
PaigeMiller
Diamond | Level 26

I think you need to define the problem more completely for us.

 

What is the criterion to determine the "largest week"? Also, there appear to be two different columns that could be month, which are you referring to?

--
Paige Miller
WilliamB
Obsidian | Level 7
The largest number, from the COSEM column
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc sql;
    create table want as select *,qcnum/qcden as taux format=percent8.0
    from have group by comois having cosem=max(cosem);
quit;
--
Paige Miller

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 695 views
  • 1 like
  • 2 in conversation