There were two questions:
SS-Y 202102 2 0
Aha. I understand your questions, Its a quiet complex situation. Hope I can clarify it by this. PS. Thank you for your help 🙂
Answering your 1st question. There are 3 different phases which can appear in the column PHASE (1,2 and 3). There is a possibility that a certain type can contain only phase 1 and 3 (count phase 2 is automatically zero then regardless of the quarter) there is also a possibility that a type can contain phase 1,2 and 3. But there is also a possibility that a type can contain only phase 1 (which automatically means that count type 2 and 3 are zeros regardless of the quarter).
Answering your 2nd question. The SS-Y types only contain a phase 1 and 3. So phase 2 is automatically 0. The SS-X types contains phase 1 and 2 but quarter 202001 does not contain phase 2, that's why that one contains a zero.
Conclusion: phase 1,2 and 3 always need to be counted even if a type does not contain a certain phase.
Before I put forward a solution, allow me to ask about the real data that you will be applying this to, not the 8 row data set which is clearly an example.
How many values of TYPE (after removing the last two characters, as we are doing) and how many values of quarter? Apparently, there can be at most 3 phases.
Also, do all values of QUARTER appear for all values of TYPE (after removing the last two characters)?
data intermediate;
set have;
type=substr(type,1,4);
run;
proc freq data=intermediate;
tables type*quarter*phase/list noprint out=outputdatasetname(drop=percent rename=(count=total)) sparse;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.