BookmarkSubscribeRSS Feed
lunaa
Calcite | Level 5

Name the data set Subscriptions and keep it in the Work library of SAS studio.

• Subscriptions contains exactly one observation for each unique billing account (Bill_Account) that appears in Active_Jun.

• Subscriptions contains only these variables:

o Customer identity (Customer_ID)

o Billing account (Bill_Account)

o The number of subscribed services (numeric type, one service identity = one service) as on 30 June 2011

o The number of services terminated (numeric type) between the period 1 July 2011 and 31 December 2011. A missing value of the termination date indicates the respective service identity was still active on 31 December 2011.

o A billing account’s maximum tenure days (numeric type) till 31 December 2011. It is defined as the inclusive number of days between the earliest activation date of all service identities and the latest termination date of all service identities of a billing account. If the latest termination date of a service identity was beyond 31 December 2011, it is treated as 31 December 2011. For example, if a billing account has two service identities, one activated on 1 June 2011 and terminated on '.' (i.e., still active on 31 December 2011) and the other activated on 1 April 2011 and terminated on 31 July 2011. Then this account’s maximum number of tenure days is the difference

 

My code like this:

data Subscriptions;
set Active_Jun;
if '1JUL2011'd<=termination_date<='31DEC2011'd then no_of_service+1;
else if termination_date='' then no_of_service=0;
output;

How should I write the code for number of subscribed services and max account tenure days?

Thank You🙏螢幕截圖 2022-11-29 下午1.31.49.png

3 REPLIES 3
lunaa
Calcite | Level 5

Name the data set Subscriptions and keep it in the Work library of SAS studio.

• Subscriptions contains exactly one observation for each unique billing account (Bill_Account) that appears in Active_Jun.

• Subscriptions contains only these variables:

o Customer identity (Customer_ID)

o Billing account (Bill_Account)

o The number of subscribed services (numeric type, one service identity = one service) as on 30 June 2011

o The number of services terminated (numeric type) between the period 1 July 2011 and 31 December 2011. A missing value of the termination date indicates the respective service identity was still active on 31 December 2011.

o A billing account’s maximum tenure days (numeric type) till 31 December 2011. It is defined as the inclusive number of days between the earliest activation date of all service identities and the latest termination date of all service identities of a billing account. If the latest termination date of a service identity was beyond 31 December 2011, it is treated as 31 December 2011. For example, if a billing account has two service identities, one activated on 1 June 2011 and terminated on '.' (i.e., still active on 31 December 2011) and the other activated on 1 April 2011 and terminated on 31 July 2011. Then this account’s maximum number of tenure days is the difference

 

My code like this:

data Subscriptions;
set Active_Jun;
if '1JUL2011'd<=termination_date<='31DEC2011'd then no_of_service+1;
else if termination_date='' then no_of_service=0;
output;

How should I write the code for number of subscribed services and max account tenure days?

Thank You🙏

螢幕截圖 2022-11-29 下午1.31.49.png

tarheel13
Rhodochrosite | Level 12

please post your data as datalines if you want help.

ballardw
Super User

This sounds a lot like homework. As such a general "how to do x" request may get you answers that involve things not covered by your course work yet. Have you encountered Proc Means? Proc Report? Proc Tabulate? These procedures are quite often used for summaries instead of writing data steps.

 

The actual structure and content of data set you have does make a big difference in what approach is taken. From your "description" I am not sure that you are describing the data or the requirement. If that is the requirement then without data examples I have no clue how to start. If there is data, then some example records helps.

 

It sounds like you need to group results by Customer_id and Bill_account and then SUM several other variables (names not provided). If you have been exposed to Proc Report the previous sentence could be providing a very large economy sized hint on one solution.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 791 views
  • 0 likes
  • 3 in conversation