BookmarkSubscribeRSS Feed
JerryW
Calcite | Level 5

I vaguely remember by using Proc Report we can produce a report with all variables listed vertically for each of the observations in the dataset, but I couldnt remember the syntax for that. Could someone kindly remind me the syntax?

 

For example, if I have a data set with the following observations

 

Name   Sex   Age

John     M      30

Max      M      56

Ann       F      19

 

I would like to have a report displayed this way

 

Name: John

Sex:     M

Age:     30

 

Name:  Max

Sex:      M

Age:      56

 

Name:   Ann

Sex:       F

Age:      19

4 REPLIES 4
slchen
Lapis Lazuli | Level 10
option nodate;
ods pdf file='c:\temp\test.pdf' ;
title "";
proc report data=sashelp.class(obs=3) nowd headline headskip;
define name/group ;
break after name/ page;
run;
ods pdf close;
JerryW
Calcite | Level 5

Thank you, but this would still list the variables as columns , not vertically as shown in the example, right?

Tom
Super User Tom
Super User

Are you sure you are not thinking about PROC FSEDIT with the PRINTALL option?

Or if you do not have that licensed just use a data step.

 

 

data _null_;
   file print ;
  set sashelp.class ;
  put (_all_) (=/);
run;
slchen
Lapis Lazuli | Level 10

There are too many steps, I believe there is simple way.

 

proc sort data=sashelp.class out=temp;
by name;
run;

proc transpose data=temp out=temp1;
by name;
var name--age;
run;

data want;
  set temp1;
  if mod(_n_,3)=1 then k+1;
  flag=k;
  Name=cats(_name_,':');
  keep flag name col1;
run;


proc report data=want(obs=3) nowd headskip headline noheader;
define flag/order noprint;
break after flag/page;
run

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
  • 4 replies
  • 1233 views
  • 0 likes
  • 3 in conversation