BookmarkSubscribeRSS Feed
JohnnySas
Calcite | Level 5

I just completed a proc transpose.

 

proc transpose data=WORK.SIGN1 out=WORK.SIGN2 prefix=E_;
by CLIENT_XID;
id SQID;
var EMAIL;
run;

 

The E_  = E1, E2, E3, E4, E.....(nth)

 

Question: How do I use an array in the next data step to:

 

1. dynamically select all the E1,E2, E3, E....(nth) from WORK.SIGN2

 

Thank You

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

What do you want to do?

Like this?

sum( of E_: )

 

JohnnySas
Calcite | Level 5

Thank You for the reply.

 

All i want is:

 

do a dynamic creation of a select from the result of the proc transpose.

 

select 

E_1, E_2,E_3, E,....(nth)

from ....;

 

Reeza
Super User
SQL does not support variable lists. A data step does, so using a data step is a better option.
ChrisNZ
Tourmaline | Level 20

select

t1.*

....

from TABLE ( keep= E_: .... )  t1

....

;

Reeza
Super User

Here are a few ways. 

 

https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html

 


@JohnnySas wrote:

I just completed a proc transpose.

 

proc transpose data=WORK.SIGN1 out=WORK.SIGN2 prefix=E_;
by CLIENT_XID;
id SQID;
var EMAIL;
run;

 

The E_  = E1, E2, E3, E4, E.....(nth)

 

Question: How do I use an array in the next data step to:

 

1. dynamically select all the E1,E2, E3, E....(nth) from WORK.SIGN2

 

Thank You


 

Astounding
PROC Star

The next step can identify all variable names that begin with E_ into an array in this way:

 

data want;

set sign2;

array emails {*} E_: ;

*** add logic here if desired ;

run;

 

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1666 views
  • 2 likes
  • 4 in conversation