SAS - plz help

Hi ee,


w - 1
variant  a    b  c  d                    
test1     1    1  1  1
test2     1    1  1  1
test3     1    1  1  1
test4     1    1  1  1


w-2

variant  a  b  c  d
test1     1  1  1  1
test2     1  1  1  1
test3     1  1  1  1
test4     1  1  1  1



output to be

metric              test1                                test2                      test3                             test4
             cum  week1 week2        cum  week1 week2      cum  week1 week2  cum week1 week2
a            2         1          1               2        1           1            2          1         1         2         1         1
b            2         1          1               2        1           1            2          1         1         2         1         1
c            2         1          1               2        1           1            2          1         1         2         1         1
d            2         1          1               2        1           1            2          1         1         2         1         1

I am tring to using proc transpose and proc report.

plz help
hello214Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aloysius LowCommented:
0
hello214Author Commented:
yes. Probably. I am new to experts exchange and my friend has the account. Just found out he also asked the same question.

Sorry for the repetition can you please help.
0
sdstuberCommented:
this one is tricky because you must pivot and unpivot on the same results.
in 11g it would be easier because pivot and unpivot are built in commands but here you'll have to do it with conditional aggregationd:

try this...

SELECT   metric,
         MAX(
             CASE
                 WHEN w1.variant = 'test1' AND metric = 'a' THEN w1.a + w2.a
                 WHEN w1.variant = 'test1' AND metric = 'b' THEN w1.b + w2.b
                 WHEN w1.variant = 'test1' AND metric = 'c' THEN w1.c + w2.c
                 WHEN w1.variant = 'test1' AND metric = 'd' THEN w1.d + w2.d
             END)
             test1_cum,
         MAX(
             CASE
                 WHEN w1.variant = 'test1' AND metric = 'a' THEN w1.a
                 WHEN w1.variant = 'test1' AND metric = 'b' THEN w1.b
                 WHEN w1.variant = 'test1' AND metric = 'c' THEN w1.c
                 WHEN w1.variant = 'test1' AND metric = 'd' THEN w1.d
             END)
             test1_week1,
         MAX(
             CASE
                 WHEN w1.variant = 'test1' AND metric = 'a' THEN w2.a
                 WHEN w1.variant = 'test1' AND metric = 'b' THEN w2.b
                 WHEN w1.variant = 'test1' AND metric = 'c' THEN w2.c
                 WHEN w1.variant = 'test1' AND metric = 'd' THEN w2.d
             END)
             test1_week2,
         MAX(
             CASE
                 WHEN w1.variant = 'test1' AND metric = 'a' THEN w1.a + w2.a
                 WHEN w1.variant = 'test1' AND metric = 'b' THEN w1.b + w2.b
                 WHEN w1.variant = 'test1' AND metric = 'c' THEN w1.c + w2.c
                 WHEN w1.variant = 'test1' AND metric = 'd' THEN w1.d + w2.d
             END)
             test1_cum,
         MAX(
             CASE
                 WHEN w1.variant = 'test2' AND metric = 'a' THEN w1.a
                 WHEN w1.variant = 'test2' AND metric = 'b' THEN w1.b
                 WHEN w1.variant = 'test2' AND metric = 'c' THEN w1.c
                 WHEN w1.variant = 'test2' AND metric = 'd' THEN w1.d
             END)
             test1_week1,
         MAX(
             CASE
                 WHEN w1.variant = 'test2' AND metric = 'a' THEN w2.a
                 WHEN w1.variant = 'test2' AND metric = 'b' THEN w2.b
                 WHEN w1.variant = 'test2' AND metric = 'c' THEN w2.c
                 WHEN w1.variant = 'test2' AND metric = 'd' THEN w2.d
             END)
             test1_week2,
         MAX(
             CASE
                 WHEN w1.variant = 'test3' AND metric = 'a' THEN w1.a + w2.a
                 WHEN w1.variant = 'test3' AND metric = 'b' THEN w1.b + w2.b
                 WHEN w1.variant = 'test3' AND metric = 'c' THEN w1.c + w2.c
                 WHEN w1.variant = 'test3' AND metric = 'd' THEN w1.d + w2.d
             END)
             test3_cum,
         MAX(
             CASE
                 WHEN w1.variant = 'test3' AND metric = 'a' THEN w1.a
                 WHEN w1.variant = 'test3' AND metric = 'b' THEN w1.b
                 WHEN w1.variant = 'test3' AND metric = 'c' THEN w1.c
                 WHEN w1.variant = 'test3' AND metric = 'd' THEN w1.d
             END)
             test3_week1,
         MAX(
             CASE
                 WHEN w1.variant = 'test3' AND metric = 'a' THEN w2.a
                 WHEN w1.variant = 'test3' AND metric = 'b' THEN w2.b
                 WHEN w1.variant = 'test3' AND metric = 'c' THEN w2.c
                 WHEN w1.variant = 'test3' AND metric = 'd' THEN w2.d
             END)
             test3_week2,
         MAX(
             CASE
                 WHEN w1.variant = 'test4' AND metric = 'a' THEN w1.a + w2.a
                 WHEN w1.variant = 'test4' AND metric = 'b' THEN w1.b + w2.b
                 WHEN w1.variant = 'test4' AND metric = 'c' THEN w1.c + w2.c
                 WHEN w1.variant = 'test4' AND metric = 'd' THEN w1.d + w2.d
             END)
             test4_cum,
         MAX(
             CASE
                 WHEN w1.variant = 'test4' AND metric = 'a' THEN w1.a
                 WHEN w1.variant = 'test4' AND metric = 'b' THEN w1.b
                 WHEN w1.variant = 'test4' AND metric = 'c' THEN w1.c
                 WHEN w1.variant = 'test4' AND metric = 'd' THEN w1.d
             END)
             test4_week1,
         MAX(
             CASE
                 WHEN w1.variant = 'test4' AND metric = 'a' THEN w2.a
                 WHEN w1.variant = 'test4' AND metric = 'b' THEN w2.b
                 WHEN w1.variant = 'test4' AND metric = 'c' THEN w2.c
                 WHEN w1.variant = 'test4' AND metric = 'd' THEN w2.d
             END)
             test4_week2
    FROM w1,
         w2,
         (SELECT 'a' metric FROM DUAL
          UNION ALL
          SELECT 'b' FROM DUAL
          UNION ALL
          SELECT 'c' FROM DUAL
          UNION ALL
          SELECT 'd' FROM DUAL)
   WHERE w1.variant = w2.variant
GROUP BY metric
ORDER BY metric

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DavidSenior Oracle Database AdministratorCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.