Help using Base SAS procedures

Creating the desired table

Reply
Occasional Contributor
Posts: 9

Creating the desired table

Hello,

Here is the table I have currently:

10050020050020050020011982219864..
2005002005002005002001..1982219864
30160020160020160020011984319864..
4016002016002016002002..1984319843
50170020170020170020061982019822..
6017002017002017002006..1982019822
70200020200020200020011983619836..
8020002020002020002001..1983619836
90210020210020210020011982419824..
10021002021002021002001..1982419824
110490020490020490020011984519864..
12049002049002049002003..1986419864

I am looking for a way to basically combine two lines into one line... for example, combine obs1 with obs2, obs3 with obs4 etc. The problem is that there are missing values for the different variables. So basically I would like this table to only be 6 rows with all the information accros one straight line. Does anyone know how to do this?

Thanks!

-Tyler

Respected Advisor
Posts: 3,124

Re: Creating the desired table

Something like this?


data have;

     infile cards dlm='09'x;

     input v1-v9;

     cards;

1    005  002  005002     005002001  19822 19864 .    .

2    005  002  005002     005002001  .    .    19822 19864

3    016  002  016002     016002001  19843 19864 .    .

4    016  002  016002     016002002  .    .    19843 19843

5    017  002  017002     017002006  19820 19822 .    .

6    017  002  017002     017002006  .    .    19820 19822

7    020  002  020002     020002001  19836 19836 .    .

8    020  002  020002     020002001  .    .    19836 19836

9    021  002  021002     021002001  19824 19824 .    .

10   021  002  021002     021002001  .    .    19824 19824

11   049  002  049002     049002001  19845 19864 .    .

12   049  002  049002     049002003  .    .    19864 19864

;

data want;

     update have (obs=0) have;

     by v2;

run;


Haikuo

Trusted Advisor
Posts: 1,204

Re: Creating the desired table

proc stdize data=have out=want reponly method=median;
by v2;
var v6-v9;
run;

data final;
set want;
by v2;
if first.v2;
run;

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