BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
harshpatel
Quartz | Level 8

Hi,

I need to compare this quarter vs previous quarter with the following output

From input table, i need to compare 2 quarters current and previous

Input table:

ID  Repdate         Amount

1    31DEC2020    2000

1    31DEC2021     3000

1    30SEP2020    1500

1    30SEP2021     3000

 

Output table:

ID  Repdate         Amount     Previousqtr    Amount

1    31DEC2020    2000         30SEP2020    1500

1    31DEC2021     3000         30SEP2021      3000

 

Thanks in advance

 

1 ACCEPTED SOLUTION
9 REPLIES 9
yabwon
Onyx | Level 15

What did you try up to now?

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



harshpatel
Quartz | Level 8
Hi, i want to compare current quarter vs previous quarter in the sas dataset itself as i have mentioned the output table
yabwon
Onyx | Level 15

I didn't asked what do you want (I can tell that from the first post). I asked what did you try so far? What code have you wrote?

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



harshpatel
Quartz | Level 8
Hi, below is my code, but i want amount column as well which is previous quarter amount
data y ;
set test;
format end_last_q date9.;
end_last_q = intnx('qtr', repdate, -1, 'end');
put end_last_q;
run;
andreas_lds
Jade | Level 19

Can you post the input table as working data step code?

You want the output as html/pdf/excel, not as dataset, right?

harshpatel
Quartz | Level 8
Hi, i want sas dataset only
harshpatel
Quartz | Level 8
Hi, i tried below code but i am not getting another amount column which is previous quarter amount
data y ;
set test;
format end_last_q date9.;
end_last_q = intnx('qtr', repdate, -1, 'end');
put end_last_q;
run;
harshpatel
Quartz | Level 8
Thanks, it works

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1155 views
  • 1 like
  • 4 in conversation