|
|
how to export only few variables using proc export
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?
|
|
0
|
|
|
|
Reply
|
rish_n (1)
|
4/1/2010 5:44:09 AM |
|
On Apr 1, 10:44=A0am, rishi <ris...@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 =3D or keep=3D dataset option for your code.
Sample code:
DATA TEST;
a =3D 1;
b =3D 2;
c =3D 3;
output;
a =3D 1;
b =3D 2;
c =3D 3;
output;
RUN;
PROC EXPORT DATA =3D TEST(keep=3D a b) dbms=3Dexcel2000 OUTFILE =3D "c:\tes=
t";
RUN;
Hope this suits your purpose.
Thanks and Regards,
Amar Mundankar.
|
|
0
|
|
|
|
Reply
|
Amar
|
4/1/2010 7:44:11 AM
|
|
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 =3D 1 to 20;
if mod(obs,_n_) =3D 0 then group1 =3D 'A';
else group1 =3D 'B';
if 1 <=3D obs <=3D 15 then group2 =3D 'X';
else group2 =3D 'Y';
if 1 <=3D obs <=3D 7 then var1 =3D 10;
else
if 8 <=3D obs <=3D 13 then var1 =3D 12;
else var1 =3D 20;
output;
end;
run;
proc export data=3Dmydata(drop=3Dgroup1 where=3D(var1 =3D> 12))
outfile=3D"c:\test.xls";
run;
Hope this helps...
Andrew Karp
Sierra Information Services
http://www.sierrainformation.com
On Apr 1, 12:44=EF=BF=BDam, Amar Mundankar <amarmundan...@gmail.com> wrote:
> On Apr 1, 10:44=EF=BF=BDam, rishi <ris...@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 =3D or keep=3D dataset option for your code.
>
> Sample code:
>
> DATA TEST;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BDa =3D 1;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD b =3D 2;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD c =3D 3;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD output;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BDa =3D 1;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD b =3D 2;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD c =3D 3;
> =EF=BF=BD =EF=BF=BD =EF=BF=BD =EF=BF=BD output;
>
> RUN;
> PROC EXPORT DATA =3D TEST(keep=3D a b) dbms=3Dexcel2000 OUTFILE =3D "c:\t=
est";
> RUN;
>
> Hope this suits your purpose.
>
> Thanks and Regards,
> Amar Mundankar.
|
|
0
|
|
|
|
Reply
|
Andrew
|
4/1/2010 3:25:03 PM
|
|
|
2 Replies
608 Views
(page loaded in 0.075 seconds)
|
|
|
|
|
|
|
|
|