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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 718 views
  • 0 likes
  • 2 in conversation