Issue with using array statement to rotate dataset

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Issue with using array statement to rotate dataset

Hi all,

The following might easily be down in several ways. But I was wondering if it can be done by using arrays specifically?

I have the following dataset:

Customer_IDMonth1Month2Month3Month4Month5Month6Month7Month8Month9Month10Month11Month12
5478
5126.8
552.5
533.8
1032.6
10250.8
10143.3
1178.2
12117.6
1248.4
1287.2
24195.6
2446.9
2470.2
2446.1

I was hoping to keep one observation for each customer. The desired output is as follows:

Customer_IDMonth1Month2Month3Month4Month5Month6Month7Month8Month9Month10Month11Month12
5478126.852.533.8
1032.6250.8143.3
1178.2
12117.648.487.2
24195.646.970.246.1

I am relatively new to arrays so would greatly appreciate any suggestions.

Thanks.


Accepted Solutions
Solution
‎10-03-2012 10:40 PM
Respected Advisor
Posts: 3,799

Re: Issue with using array statement to rotate dataset

You don't need an array.  Use UPDATE.

data flater;

  set UPDATE flat(obs=0) flat;

   by customer_ID;

   run;

Message was edited by: data _null_

View solution in original post


All Replies
Solution
‎10-03-2012 10:40 PM
Respected Advisor
Posts: 3,799

Re: Issue with using array statement to rotate dataset

You don't need an array.  Use UPDATE.

data flater;

  set UPDATE flat(obs=0) flat;

   by customer_ID;

   run;

Message was edited by: data _null_

Occasional Contributor
Posts: 6

Re: Issue with using array statement to rotate dataset

Posted in reply to data_null__

Hi data_null_,

Thanks for your reply. However it does not seem to work for me. I understand your point that the master and transaction dataset should be the same except that the master dataset is set to zero observations. However the output I get is the same as the initial output.

Cheers.

Respected Advisor
Posts: 3,156

Re: Issue with using array statement to rotate dataset

DN had a typo, you need to replace his 'set' with 'update' as he promoted:

data flater;

   update flat(obs=0) flat;

   by customer_ID;

   run;

Haikuo

Occasional Contributor
Posts: 6

Re: Issue with using array statement to rotate dataset

Thanks, Hai.kuo. I did recognize the typo and replaced the set with update. However problem remains.

Occasional Contributor
Posts: 6

Re: Issue with using array statement to rotate dataset

Well, interestingly after n times of unsuccessful trial, the same set of codes worked out for me!

Thanks again DN and Hai.kuo.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 239 views
  • 3 likes
  • 3 in conversation