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

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

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

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

PG
BETO
Fluorite | Level 6

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

PGStats
Opal | Level 21

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

PG
naveen_srini
Quartz | Level 8

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

sas-innovate-2024.png

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.

 

Register now!

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
  • 4 replies
  • 1238 views
  • 0 likes
  • 3 in conversation