## transposing to make one record per id.

Solved
Regular Contributor
Posts: 214

# transposing to make one record per id.

I am stuck up with transposing as i get multople observations if i try to transpose as the paramcd has multiple observations. attached code i am using and i need single observation per subject. any suggestion where am i going wrong

```proc sort data=Anl1
out= anl2;
by studyid usubjid paramcd aval;
run;

data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
set anl2;
by studyid usubjid paramcd aval;
seq+1;
if first.paramcd then seq=1;
run;

proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
by studyid usubjid;
id paramcd seq;
var aval;
run;
```

Accepted Solutions
Solution
‎12-05-2017 03:44 AM
Super User
Posts: 9,840

## Re: transposing to make one record per id.

[ Edited ]

This:

```     id paramcd seq;
```

Wont work.   Update here:

```data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
set anl2;
by studyid usubjid paramcd aval;  retain seq;
if first.paramcd then seq=1;   else seq+1;  paramcd=cats(paramcd,put(seq,best.));
run;```

Then put:

```proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
by studyid usubjid;
id paramcd;
var aval;
run;```

Ie make the variable paramcd cd unique by adding the incremental number to it (when you have the sequence correct).

All Replies
Solution
‎12-05-2017 03:44 AM
Super User
Posts: 9,840

## Re: transposing to make one record per id.

[ Edited ]

This:

```     id paramcd seq;
```

Wont work.   Update here:

```data Id_adds (keep=studyid usubjid aval avalc paramcd seq);
set anl2;
by studyid usubjid paramcd aval;  retain seq;
if first.paramcd then seq=1;   else seq+1;  paramcd=cats(paramcd,put(seq,best.));
run;```

Then put:

```proc transpose data=Id_adds out=Id_trans(drop=_name_ _label_) ;
by studyid usubjid;
id paramcd;
var aval;
run;```

Ie make the variable paramcd cd unique by adding the incremental number to it (when you have the sequence correct).

☑ This topic is solved.