BookmarkSubscribeRSS Feed
usuario_estudo
Calcite | Level 5

Hi,

 

I need a function in SAS that reads horizontally.

 

I have to create a variable "Number of completed months" that returns the value of months that are filled until it arrives empty (missing ".").

 

Example: 

 

 

IDMONTH_1MONTH_2MONTH_3MONTH_4MONTH_5MONTH_6MONTH_7MONTH_8"Number of completed months" 
110223165....4
2152111......2
3197198.....3
43386759321284..6
5100176902208188887788

 

Thnak you!

1 REPLY 1
Astounding
PROC Star

SAS can do this easily if the data behaves:

 

n_complete = n(of month_1 - month_8);

 

However, if you have the possibility of missing values in the middle:

 

month_1 = 10

month_2 = .

month_3 = 22

 

You would need to decide if the correct result is 2 vs. should it be 3.  The programming might have to change a little.