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;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 6 replies
  • 622 views
  • 2 likes
  • 4 in conversation