Question

I am transposing a file with several million observations using

proc transpose data=click out=CLICK_transp name=test prefix=var;
by ComlogId;        
var clickthrulink_Description;
run;

However, this job takes a long time to run because some of the clickthrulink_Description have up to hundreds of observations. I need to limit the transposed variable down to 6. Is there any way to do that in SAS and would that be more efficient in terms of run time?

Was it helpful?

Solution

You have a few options.

First off, you could use a KEEP statement in the output.

proc transpose in=have out=want(keep=id col1-col6);
by id;
var myvar;
run;

This would limit what's written to the output dataset, which would limit its size greatly.

You also could use options compress=yes; which would help with your bigger issue - lots of blank data. That would significantly decrease the amount of size needed to store the observations with much fewer than the maximum number of columns.

Finally, you could limit things with a view:

data v_have/view=v_have;
set have;
by id;
if first.id then counter=0;
counter+1;
if counter<6;
run;

proc transpose data=v_have out=want;
by id;
var yourvar;
run;

That would only pass the first six observations per ID to the transpose procedure.

OTHER TIPS

You can choose 6 variable trought the data step firstly:

DATA newClick(obs=6);
SET click;
RUN;

and then use the transpose procedure with a new data newClick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top