DATA Step, Macro, Functions and more

Adding column with By day entry

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Adding column with By day entry

[ Edited ]

Hi Guys,

 

I am very new to SAS. 

I need to add a column which tells me which day of the campaign it is. Like: 

as you can see above, I need to add by_day column which tells me which day it is on the cpgn. Can I get some inputs asap. 

Greatly appreciated. Please refer the file attached

 

CPGN_ID OFFR_I INVOICE_DT By_DAY
3               2            20160803      Day 1
3               2            20160803      Day 1
3               2            20160804      Day 2
3               2            20160804      Day 2


Accepted Solutions
Solution
‎12-16-2016 05:36 AM
Super User
Posts: 19,805

Re: Adding column with By day entry

Posted in reply to Amritta_26

What is the format and type for your date variable? Use PROC CONTENTS. 

 

Also, what happens if you have gaps in your dates, is your counter still consecutive. And will you want calculations based on date, ie durations? If so, you may want to consider storing it as a number rather than Day 1/Day 2 

View solution in original post


All Replies
Solution
‎12-16-2016 05:36 AM
Super User
Posts: 19,805

Re: Adding column with By day entry

Posted in reply to Amritta_26

What is the format and type for your date variable? Use PROC CONTENTS. 

 

Also, what happens if you have gaps in your dates, is your counter still consecutive. And will you want calculations based on date, ie durations? If so, you may want to consider storing it as a number rather than Day 1/Day 2 

New Contributor
Posts: 3

Re: Adding column with By day entry

Hi,

Well the data is already there is number format, next to it i have to convert it into by day and insert it for evaluation purpose. 

date is in numeric, length is 8, format is 11.

 

I hope this answers your question

Super User
Posts: 19,805

Re: Adding column with By day entry

Posted in reply to Amritta_26

 Many people will not download Excel files, please include your data as text in your post 

New Contributor
Posts: 3

Re: Adding column with By day entry

Did you get my question? Let me know if you can help out!
Super User
Posts: 19,805

Re: Adding column with By day entry

Posted in reply to Amritta_26

Data want;

set have;

 

by date;

 

if first.date day_counter + 1;

 

return;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 236 views
  • 0 likes
  • 2 in conversation