04-05-2018 08:50 AM
Hi SAS Community,
I am currently running a Proc Freq to create a two way table. When I run the procedure using the code below, it creates a table, but it does not include the transition from having a value to missing.
proc freq data=new; tables Prior_Year*Current_Year/ out=test; run;
An example of what my data looks like is
In this example, I would expect out=test to look like
Prior Year Current_year Count
1 2 2
1 3 1
but, it does not include the transition from 1 to when there is null in the Current_Year column. Does anyone know an option or technique that I can use to include the count of the values that start in the Prior_Year but are missing in the Current_Year. I tried the missing option, but that didn't do anything.
If anybody could help I would greatly appreciate it!
04-05-2018 09:07 AM
Thanks, I tried that already and it still doesn't give me the missing values. It also isn't giving me all the possible combinations like it is supposed to.
04-05-2018 09:20 AM
Given your example data, it works:
data have; input Prior_Year Current_Year; cards; 1 2 1 3 1 2 1 . ; run; proc freq data=have noprint; tables Prior_Year*Current_Year/ missing out=want; run; proc print data=want noobs; run;
Prior_ Current_ Year Year COUNT PERCENT 1 . 1 25 1 2 2 50 1 3 1 25
Just the order is different.
04-05-2018 10:01 AM
Thanks for your help. You are right, I sorted my results by Current_Year and there was one instance where the Current_Year =. . It seems like the issue is somewhere in my data because there should be many more occurrences where there are transitions to null. I apologize for wasting anybody's time.