BookmarkSubscribeRSS Feed
Tommy1
Quartz | Level 8

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

4 REPLIES 4
PaigeMiller
Diamond | Level 26
tables Prior_Year*Current_Year/  out=test missing;
--
Paige Miller
Tommy1
Quartz | Level 8

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

Kurt_Bremser
Super User

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.

Tommy1
Quartz | Level 8

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 653 views
  • 2 likes
  • 3 in conversation