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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 762 views
  • 0 likes
  • 3 in conversation