Learning SAS? Welcome to the exclusive online community for all SAS learners.

Create new variable with column value

Reply
Occasional Contributor
Posts: 6

Create new variable with column value

Hi,

we are currently doing some data aggregation via sas studio.

In the table below you can see how the data currently looks like. In our data we have several custIDs, and the goal is to reduce the data to 1 row per customer with newly created variables. We now want to create new variables with name of the T_WG_P variable and the values from the Revenue column.

Obs.CustIDAvgRev.T_WG_PCountTransactRevenue
111062.54T_1_244250.16
21919.48T_1_398275.28
311194.62T_1_455973.10

What we now need is something like a call symput statement but only for non-macro variables to use the value from T_WG_P as a variable name and to assign the revenue as a value to it.

Or maybe you have a completely different approach, all help is very welcome. Smiley Happy

Thanks in advance and best regards

Jan

Super User
Posts: 10,538

Re: Create new variable with column value

Please post what you expect the output to actually look like. What happens with AvgRev and CountTransact?

Valued Guide
Posts: 858

Re: Create new variable with column value

Is this an example of what you want?  &T_1_2 = 4250.16

Super User
Posts: 10,538

Re: Create new variable with column value

proc transpose data=have out=trans

   ;

by custId;

var revenue;

id T_WG_P;

run;

Does some of what you want.

Ask a Question
Discussion stats
  • 3 replies
  • 401 views
  • 0 likes
  • 3 in conversation