BookmarkSubscribeRSS Feed
ccherrub
Obsidian | Level 7

Hi! So I have a dataset involving variables Week, ProductID, Age, TotRev, Treatment, HasVideo, and a self-created one: "Group". Each ProductID was tested for weeks and with five different categories. The varible group was made to determine if it was before or after another variable got introduced. I was struggling with how I am able to get a table with a difference of After-Before in TotalRev for each age group primarly. I was also wondering if adding in for each ProductID would be possible. Thank you!

 

Let me know if more information is needed.

 

Codes:

 

libname AEData "~/my_shared_file_links/u47408605/Data"
access=readonly;
run;
 
Proc Print data=AEData.project2 (obs=20);
run;
 
Data project2;
set aedata.project2;
if week>25 then group = "After";
else if week<25 then group = "Before";
run;
3 REPLIES 3
Patrick
Opal | Level 21

What we need is some representative sample data and desired result. This allows us to provide tested code and it also really helps to better understand what you describe.

Please provide your sample data as below:

data have;
    infile datalines truncover dsd;            
    input Week ProductId Age TotRev Treatment HasVideo Group.;                       
datalines;       
<and here sample data, comma separated>
;
ccherrub
Obsidian | Level 7

Do you mean a snapshot of my data or just a random sample? Columns are Week, ProductID, Age, TotRev, Treatment, HasVideo, and group. I'm looking to find the difference of TotRev in the years labeled as 'After' in group, deducting those labeled as 'Before' in group categorized by Age.

 

I provided pictures of data below.

 emm1.pngemm2.png

Patrick
Opal | Level 21

@ccherrub I mean sample data provided via a working SAS data step and not a screenshot so we've got something to work with and test the code we propose.

Use the data step template I've provided already to provide such a SAS data step.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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