Help using Base SAS procedures

Exporting data error

Reply
N/A
Posts: 0

Exporting data error

Hi ,
I need to export it to text file.While exporting am not getting any headers on the text file. If i use proc export am not getting variables on proper order.
Can you let me know wht to add on the code to get an header while using data_null step.

data _null_;

set Class;
file "&drv2\ABC\ABC6_Class.txt" dlm="||";

put compno clamno2 lineno ;
run;

Thanks in advance !!
Super Contributor
Super Contributor
Posts: 365

Re: Exporting data error

Posted in reply to deleted_user
Hello Raveenat,

To get a desired order one can use the RETAIN statement before SET like this:
[pre]
data _null_;
retain compno clamno2 lineno;
set Class;
file "&drv2\ABC\ABC6_Class.txt" dlm="||";
put compno clamno2 lineno;
run;
[/pre]
Sincerely,
SPR
N/A
Posts: 0

Re: Exporting data error

Hi SPR,

My intention is to get an header while exporting using data _null_ step.
If i use proc export , then the variables are not on the desirable order.

Thanks
Super Contributor
Super Contributor
Posts: 365

Re: Exporting data error

Posted in reply to deleted_user
Did you try retain?
N/A
Posts: 0

Re: Exporting data error

Yes SPR I tried as below code, but am not getting an header

data class;
input var1 var2 var3;
cards;
1 2 3
4 5 6
7 8 9
;
run;
data _null_;
retain var1 var2 var3;
set Class;
file "C:\Documents and Settings\Desktop\output.txt" dlm="||";
put var1 var2 var3;
run;
Super User
Posts: 11,343

Re: Exporting data error

Posted in reply to deleted_user
if _n_ = 1 put "header 1" "header 2" "header3";

is a minimal way to get something as a header.
Ask a Question
Discussion stats
  • 5 replies
  • 139 views
  • 0 likes
  • 3 in conversation