@bonedog wrote:
Hey!
I have a data set in SAS that I have so that a period (.) fills all blank spaces. However, when I export my file as a .txt it randomly removes some of the periods and converts them back to blanks. How can I correct this so all the periods remain? I need the periods so another program will read my set in correctly. My code is below:
PROC EXPORT data = finalpheno outfile = 'X:\FlyFiles\pheno.txt' replace; RUN;
I don't understand what you have. You have set your character variables in your SAS dataset to have periods replacing all of the spaces? So a value like 'John Smith' in a 12 character variable will have 'John.Smith..' instead?
Also if you want to write a text file why are you using PROC EXPORT instead of just using a data step with a FILE statement and PUT statement? Your code will generate a tab delimited file. Is that what you want?
proc export data=sashelp.class(obs=3) outfile='c:\downloads\class.txt' replace;
run;
114 data _null_; 115 infile 'c:\downloads\class.txt'; 116 input; 117 list; 118 run; NOTE: The infile 'c:\downloads\class.txt' is: Filename=c:\downloads\class.txt, RECFM=V,LRECL=32767,File Size (bytes)=92, Last Modified=17Oct2019:12:21:52, Create Time=17Oct2019:12:21:09 RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 CHAR Name.Sex.Age.Height.Weight 26 ZONE 46660567046604666670566667 NUMR E1D59358917598597849759784 2 CHAR Alfred.M.14.69.112.5 20 ZONE 46676604033033033323 NUMR 1C62549D9149699112E5 3 CHAR Alice.F.13.56.5.84 18 ZONE 466660403303323033 NUMR 1C93596913956E5984 4 CHAR Barbara.F.13.65.3.98 20 ZONE 46766760403303323033 NUMR 212212196913965E3998 NOTE: 4 records were read from the infile 'c:\downloads\class.txt'. The minimum record length was 18. The maximum record length was 26.
If you write you own program to generate the file you can generate it in almost any format you can imagine (and describe).
So please describe exactly, with examples, what format you have (your SAS datset) and what format you want to create (your text file).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: