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.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1251 views
  • 0 likes
  • 2 in conversation