BookmarkSubscribeRSS Feed
forumsguy
Fluorite | Level 6

Hi,

I have a dataset which looks like this

NameCity
JohnWashington
JohnChicago
JohnNewyork
MaryWashington
MaryDallas

And I want to Transpose it based on Group of Name and City output should be something like this

Output_Report
John
Washington
Chicago
Newyork
Mary
Washington
Dallas

Is it possible to create a dataset/PDF report like this ?

Any help is really appreciated

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Question is, why would you want to, its then hard to see what is a name and what is a city.  If you have to then:

data want;

     set have;

     by name;

     if first.name then do;    

          output_report=name;

          output;

          output_report=city;

          output;

     end;

     else do;

          output_report=city;

          output;

     end;

run;

However to my mind it makes more sense to report both columns, but just group the first in a report:

proc report data=have;

     columns name city;

     define name / order "Name";

     define city / "City";

run;

This will display:

Name     City

John       Washington

               Chicago

               NewYork

Mary       Washington

               ...

Ksharp
Super User

You really should post it at ODS and Report forum if it is a proc report problem.

data have;
input  Name $     City : $20.;
cards;
John     Washington
John     Chicago
John     Newyork
Mary     Washington
Mary     Dallas
;
run;
 
proc report data=have nowd;
     columns name city;
     define name / order "Name" noprint;
     define city / "City";
      compute before name;
       line name $;
      endcomp;
run;


Xia Keshan

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 753 views
  • 0 likes
  • 3 in conversation