BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tallkell
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
spljon
SAS Employee

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)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 602 views
  • 3 likes
  • 2 in conversation