hi
i have a table that looks like this
number. Value. Balance
1. 1. 1
1. 2. 5
1. 3. 10
1. 4. 20
I Would like it to look like this
number Balance. 1. 2. 3. 4.
1 36 1. 5. 10 20
thanks again
Like this :
data have;
input number Value Balance;
datalines;
1. 1. 1
1. 2. 5
1. 3. 10
1. 4. 20
;
proc transpose data=have out=temp(drop=_:) prefix=v_;
by number;
id value; idlabel value;
var balance;
run;
data want;
length number balance 8;
set temp;
balance = sum(of v_:);
run;
PG
Like this :
data have;
input number Value Balance;
datalines;
1. 1. 1
1. 2. 5
1. 3. 10
1. 4. 20
;
proc transpose data=have out=temp(drop=_:) prefix=v_;
by number;
id value; idlabel value;
var balance;
run;
data want;
length number balance 8;
set temp;
balance = sum(of v_:);
run;
PG
PGSTATS
i using your example I tweaked it to fit my code
proc sort data = part2;
by number;
run;
proc transpose data = part2 out temp(drop=_:) prefix = v_;
by number ;
id facevalue; idlabel facevalue;
var ebal;
run;
i get this error message
error The id value "v_1_00" occurs twice in the same by group.
note the above message was for the following by group number = 4407
it happens six more time same error message different number
tthanks for your assistance
It could be that
1) You have duplicate values for facevalue in some number groups or
2) The format associated with facevalue makes certain values look the same when creating new column names. I.e. 1.001 and 1.002 with format 5.2 will both generate the same variable name v_1_00
Make sure that all facevalue values are unique within number groups and that they also look unique when formatted.
PG
data have;
input number Value Balance;
datalines;
1. 1. 1
1. 2. 5
1. 3. 10
1. 4. 20
;
data want;
set have(rename=(balance=b)) end=last;
array v(4);
retain v;
v(_n_)=b;
if last then
do;
balance=sum(of v{*});
output;
end;
drop value B;
run;
Regards,
Naveen Srinivasan
L&T Infotech
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.