BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Amritta_26
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

5 REPLIES 5
Reeza
Super User

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 

Amritta_26
Calcite | Level 5

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

Reeza
Super User

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

Amritta_26
Calcite | Level 5
Did you get my question? Let me know if you can help out!
Reeza
Super User

Data want;

set have;

 

by date;

 

if first.date day_counter + 1;

 

return;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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