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
Prior_Year Current_Year
1 2
1 3
1 2
1
In this example, I would expect out=test to look like
Prior Year Current_year Count
1 2 2
1 3 1
1 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!
Thanks,
Tom
tables Prior_Year*Current_Year/ out=test missing;
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.
Thanks,
Tom
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;
Result:
Prior_ Current_ Year Year COUNT PERCENT 1 . 1 25 1 2 2 50 1 3 1 25
Just the order is different.
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.
Thanks,
Tom
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!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: