Reputation: 307
I'm new to SAS and using put
in the output of a delimited data file but a couple of questions.
replace
? I tried and the code error'd out.Any help would be greatly appreciated.
Thanks!
data _null_;
set datain_20130108;
file 'C:\data\dataout_20130108.dlm';
put "!" id "|" var1 "|" var2 "|" var3 "|" var4 "|" var5 "|" var6 "~";
run;
Upvotes: 3
Views: 268
Reputation: 63424
Why not just put out a delimited file the normal way? You'll have to do some goofy things to get the leading/trailing characters (which I'd be very curious why they exist) but it's probably simpler than manually delimiting the file.
data _null_;
set datain_20130108;
file 'C:\data\dataout_20130108.dlm' dlm='|';
idtemp= cats("!", id);
vartemp=cats(var6,'~');
put id $ var1 var2 var3 var4 var5 var6 $;
run;
REPLACE is likely coming from some instruction to use PROC EXPORT. If you don't have REPLACE on PROC EXPORT, it won't overwrite a file. SAS data steps will replace files without requiring the option.
proc export data=datain_20130108 file='C:\data\dataout_20130108.dlm' dbms=dlm replace;
delimiter='|';
run;
However that would not give you the extra characters on the beginning and end, and I highly recommend not using PROC EXPORT for delimited files unless it's just a one-off shot - it makes all sorts of decisions for you that you're better off making yourself (formatting, etc.) and really isn't much easier than the PUT version.
Upvotes: 2
Reputation: 28391
You won't be able to use REPLACE in your PUT statement, if that is what you meant. You will need to create a new variable (using whatever functions you need) then use that variable in your PUT statement.
Upvotes: 0
Reputation: 2036
Regarding the space, use +(-1) after the variable name as shown below.
put "!" id+(-1);
Regarding the replace, I do not understand your question. See the link to replace documentation below. http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131176.htm
Upvotes: 2