From: rishi on
Hello guys,
I have to export only a few variables from my entire data set into an
excel file.
Is there any option in proc export through which I can do this,
without creating an intermediary dataset?
From: Amar Mundankar on
On Apr 1, 10:44 am, rishi <ris...(a)yahoo.co.in> wrote:
> Hello guys,
> I have to export only a few variables from my entire data set into an
> excel file.
> Is there any option in proc export through which I can do this,
> without creating an intermediary dataset?

Hi Rishi,
In proc export we can use the same data set options which we use in
normal data step.
I mean, you can use drop = or keep= dataset option for your code.

Sample code:


DATA TEST;
a = 1;
b = 2;
c = 3;
output;
a = 1;
b = 2;
c = 3;
output;

RUN;
PROC EXPORT DATA = TEST(keep= a b) dbms=excel2000 OUTFILE = "c:\test";
RUN;

Hope this suits your purpose.

Thanks and Regards,
Amar Mundankar.
From: Andrew Karp Sierra Info Services on
I'd like to offer an "add on" to Amar's post on this topic, please.

You can also use the WHERE Clause SAS Data Set option in a PROC EXPORT
"step" to select the "rows" of a SAS data set you want exported "out"
to another file time.

Here's an example:

data mydata;
do obs = 1 to 20;
if mod(obs,_n_) = 0 then group1 = 'A';
else group1 = 'B';
if 1 <= obs <= 15 then group2 = 'X';
else group2 = 'Y';
if 1 <= obs <= 7 then var1 = 10;
else
if 8 <= obs <= 13 then var1 = 12;
else var1 = 20;
output;
end;
run;

proc export data=mydata(drop=group1 where=(var1 => 12))
outfile="c:\test.xls";
run;

Hope this helps...

Andrew Karp
Sierra Information Services
http://www.sierrainformation.com

On Apr 1, 12:44�am, Amar Mundankar <amarmundan...(a)gmail.com> wrote:
> On Apr 1, 10:44�am, rishi <ris...(a)yahoo.co.in> wrote:
>
> > Hello guys,
> > I have to export only a few variables from my entire data set into an
> > excel file.
> > Is there any option in proc export through which I can do this,
> > without creating an intermediary dataset?
>
> Hi Rishi,
> In proc export we can use the same data set options which we use in
> normal data step.
> I mean, you can use drop = or keep= dataset option for your code.
>
> Sample code:
>
> DATA TEST;
> � � � � �a = 1;
> � � � � b = 2;
> � � � � c = 3;
> � � � � output;
> � � � � �a = 1;
> � � � � b = 2;
> � � � � c = 3;
> � � � � output;
>
> RUN;
> PROC EXPORT DATA = TEST(keep= a b) dbms=excel2000 OUTFILE = "c:\test";
> RUN;
>
> Hope this suits your purpose.
>
> Thanks and Regards,
> Amar Mundankar.