BookmarkSubscribeRSS Feed
Yennie
Calcite | Level 5
Hi all, I basically have two datasets as described below.

Dataset A
key year make model Bodystyle
24586A 2010 HOL COMMODORE Sedan
12692S 2010 BMW 135 Coupe
25496B 2010 TOY CAMRY Sedan
79632V 2010 VOK GOLF Hatchback
78542C 2010 MAZ 3 Hatchback


Dataset B
make model bodystyle guide_1 guide_2 guide_3 guide_4 guide_5
BMW 135 Coupe 1 2 0 0 6
BMW X5 4WD 0 10 0 5 40
TOY CAMRY Sedan 0 0 3 6 20
TOY RAV4 4WD 80 1 7 8 50

I am indexing Data A to Data B by make model and bodystyle and naming the new dataset as Dataset C.

Basically I want to be able to manipulate how Dataset C will appear in a way that retaining all the results in Data A on the top bit of Dataset C. Then leave two rows blank then present the results that match in Datset B after the blank rows.

I am not sure if this can be done in SAS. But this is an example that I'd been trying to obtain... as below -

key year make model Bodystyle guide_1 guide_2 guide_3 guide_4 guide_5
24586A 2010 HOL COMMODORE Sedan
12692S 2010 BMW 135 Coupe
25496B 2010 TOY CAMRY Sedan
79632V 2010 VOK GOLF Hatchback
78542C 2010 MAZ 3 Hatchback


key Year make model Bodystyle guide_1 guide_2 guide_3 guide_4 guide_5
KBI10B 2009 BMW 135 Coupe 1 2 0 0 6
KCU10B 2008 BMW 136 Coupe 1 3 1 1 9
KCT10B 2007 BMW 137 Coupe 2 2 5 5 10
KDJ10C 2009 TOY CAMRY Sedan 0 0 3 6 20

Hoping someone will be able to help me out on this one. Cheers.
2 REPLIES 2
1162
Calcite | Level 5
Can you explain more about what you need?

My suggestion would be to produce a report (rather than a dataset) that first prints Dataset A using one PROC PRINT then prints Dataset C using a second PROC PRINT.


If you really want a SAS Dataset with both, you could start here:

[pre]
data set4;
do until (eof);
set set1 end=eof;
output;
end;
do until (eof2);
set set3 end=eof2;
output;
end;
run;
[/pre]

The spaces can be added with a little more programming.
Patrick
Opal | Level 21
Yennie

A SAS table is not the same like an Excel spreadsheet. Adding empty rows would mean observations with all variables set to missings to the SAS table. This would influence all further calculations.

What you need is one SAS table (dataset) with all the data from table A and table B.

1. Use a datastep or PROC TRANSPOSE to bring dataset A into the structure of dataset B.
2. Create a new dataset C by combining A and B (add a variable identifying where the data comes from).
3. Use something like PROC REPORT to create the desired output (Proc Report allows you to add empty lines between by groups).

HTH
Patrick Message was edited by: Patrick

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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