Help using Base SAS procedures

Variables in order ("retain")

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 128
Accepted Solution

Variables in order ("retain")

I use "retain" to make variables in order.

But I don't know how to do the following:

I have a SAS dataset like:

A1 A2 A3 ... A300  B1 B2 B3 ... B300  C1 C2 C3 ... C300;

I want to make it in the following order;

A1 B1 C1 A2 B2 C2 A3 B3 C3 ... A300 B300 C300;

How?

Thanks


Accepted Solutions
Solution
‎05-20-2012 11:33 AM
Super Contributor
Posts: 1,636

Re: Variables in order ("retain")

untested code:

%macro test;

data want;

  retain  %do i=1 %to 300;

    a&i b&i c&i

%end;;

set have;

run;

%mend;

%test

View solution in original post


All Replies
Solution
‎05-20-2012 11:33 AM
Super Contributor
Posts: 1,636

Re: Variables in order ("retain")

untested code:

%macro test;

data want;

  retain  %do i=1 %to 300;

    a&i b&i c&i

%end;;

set have;

run;

%mend;

%test

Frequent Contributor
Posts: 128

Re: Variables in order ("retain")

@Linlin

Thanks, your code works perfectly!

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 176 views
  • 0 likes
  • 2 in conversation