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

Hi,

I have Excel file,Raw_data sheet contains the raw data and output sheet contains the desired output i am looking for.

I want to transpose the dataset, but i am not able to do that with normal trans pose procedure.

Now for example, For autos variable i have total 4 row with 1 as value and the count will be 4. Next total price will be 2.11.

similarly i want to Three variable auto , book, Intent which have count and total price for the.

The raw data and output is attached.

Will be very kindful for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

One way to do it with SQL is:

proc sql;

create table output as

select "Autos" as Query, sum(autos*DSQ) as DSQsum, sum(autos*price) as PriceSum from have

union all

select "Intent", sum(Intent*DSQ), sum(Intent*price) from have

union all

select "Book", sum(Book*DSQ), sum(Book*price) from have;

select * from output;

quit;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

One way to do it with SQL is:

proc sql;

create table output as

select "Autos" as Query, sum(autos*DSQ) as DSQsum, sum(autos*price) as PriceSum from have

union all

select "Intent", sum(Intent*DSQ), sum(Intent*price) from have

union all

select "Book", sum(Book*DSQ), sum(Book*price) from have;

select * from output;

quit;

PG

PG
sss
Fluorite | Level 6 sss
Fluorite | Level 6

Thank u PGStat. Smiley Happy it works

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