Transposing data, then produce a report for each observation

Reply
Occasional Contributor
Posts: 12

Transposing data, then produce a report for each observation

Hi,

I have some data, lets say three observations:

ID     firstname     lastname       bdate               residence     sex      score1     score2     score3     newdate

001     James         Jones          24Aug1986       Urban          M          200          458          1.25     05May2012

002     Suzie          Smith            10Mar1982       Rural           F          .               1285         0.86    04Feb2015

003     Henry          Marks           01Jun1972       Rural           M         246             324        2.06     24Sep2014

I would like to produce output that will show the data transposed, and display a report, one observation per page.

In addition, I would like to display column heading and add comment fields. As an example for obs 1.:

Variable Name          Value                         Comment1               Comment2          Comment3

ID                              001

firstname                    James

lastname                    Jones

bdate                         24Aug1986

residence                   Urban

sex                            M

score1                       200

score2                       458

score3                       1.25

newdate                     05May2012

Page 1

then a second page would display Suzie Smith's data (obs 2), etc.The comment fields are place holders for comments to be completed late.

I wonder if the transposition can be accomplished in proc transpose or SQL. Then an output file using proc report.

Thanks for you help community.

--Tim

SAS Employee
Posts: 2

Re: Transposing data, then produce a report for each observation

You need to divide your process into few steps.

Step 1: Use proc transpose to transpose your data

Step 2: Use data step to define new columns (variables) comment1, comment2, comment3

Step 3: Use proc print (or any other, as you wish) to create report and by statement (by ID) to have your report grouped by ID (every new ID will show on the separate page). To use by instruction you need to first sort data by ID (proc sort)

Occasional Contributor
Posts: 12

Re: Transposing data, then produce a report for each observation

Thanks spljon.

Ask a Question
Discussion stats
  • 2 replies
  • 348 views
  • 3 likes
  • 2 in conversation