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.
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
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
Thank u PGStat. it works
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.