BookmarkSubscribeRSS Feed
sasuser123123
Quartz | Level 8
Hello!
I've data like

Data new;
Input Country$ Name$ Tr1 Tr2 Tot;
Cards;
EUR Count 3 6 9
EUR Percent 15 30 45
NOA Count 7 4 11
NOA Percent 35 20 55
;

So Need output like....

COUNTRY TR1 TR2 TOT
EUR 3(15) 6(30) 9(45)
NOA 7(35) 4(20) 11(55)

Could anyone please help me that how to do this task..

Thank you...

Regards.

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Why do you want to do this? For reporting purposes?

sasuser123123
Quartz | Level 8
Yes
Kurt_Bremser
Super User

A first step to create the concatenated variables can be this:

proc sql;
create table want as
select
  a.country,
  cats(a.tr1,'(',b.tr1,')') as tr1,
  cats(a.tr2,'(',b.tr2,')') as tr2,
  cats(a.tot,'(',b.tot,')') as tot
from
  (select country,tr1,tr2,tot from new where name ='Count') a
inner join
  (select country,tr1,tr2,tot from new where name ='Percent') b
on a.country = b.country;
quit;
ballardw
Super User

@sasuser123123 wrote:
Hello!
I've data like

Data new;
Input Country$ Name$ Tr1 Tr2 Tot;
Cards;
EUR Count 3 6 9
EUR Percent 15 30 45
NOA Count 7 4 11
NOA Percent 35 20 55
;

So Need output like....

COUNTRY TR1 TR2 TOT
EUR 3(15) 6(30) 9(45)
NOA 7(35) 4(20) 11(55)

Could anyone please help me that how to do this task..

Thank you...

Regards.


If that data structure is the result of summarizing something it might be better off to go back to a raw form of the data and create the report you want directly. If this is the case can you provide an example of the raw data before that summary?

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1315 views
  • 0 likes
  • 4 in conversation