BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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 !!
5 REPLIES 5
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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
deleted_user
Not applicable
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
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Did you try retain?
deleted_user
Not applicable
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;
ballardw
Super User
if _n_ = 1 put "header 1" "header 2" "header3";

is a minimal way to get something as a header.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 751 views
  • 0 likes
  • 3 in conversation