BookmarkSubscribeRSS Feed
vpgodbole
Fluorite | Level 6

Hi,

 

I saw this question posted, but could not find Access part anywhere.

 

I am trying to export SAS dataset into .txt because i want it to be imported into Access. Prefer Pipe line as delimiter as my data has spaces, commas.

 

I tried using Proc export .. looks like txt export doesn't work on Windows, 

 

I tried data _null_ method, however, when i import in Access the End of record is not detected. Variables get split.

 

- Please advice. Thank you!

 

Below are the codes:

 

data _null_;

file "/data/cs/Users/Varun_Godbole/Sc2_20180626.txt" DLM='|' ;

set c2339197.Sc2 (obs=500) ;

put _all_;

run;

 

proc export data=c2339197.Sc2 (obs=500) outfile='/data/cs/Users/Varun_Godbole/Sc2_20180626.txt' dbms=dlm
replace;
delimiter='|';
run;

3 REPLIES 3
ybolduc
Quartz | Level 8

What error are you getting when you try to import the txt file produced by the proc export?

 

Thanks,

vpgodbole
Fluorite | Level 6

I see data in one variable rolling over next.

 

It gets exported, but in the txt file it gives double pipeline somewhere in the middle of variable sequence, i guess double delimiter is to indicate end of record, and should be end of record.

ballardw
Super User

Two or more consecutive delimiters in the Proc Export occurs when one or more variables are missing for that row of data.

Depending on how you import the file into Access you should get either a blank or NULL value for the variable.

 

Example code and results. You can see the double || after each F for the Sex column because all of the values for age were removed in the data step.

data work.junk;
   set sashelp.class;
   if sex='F' then age=.;
run;

proc export data=work.junk
     outfile="x:\example.txt"
     dbms=dlm
     replace;
     delimiter='|';
run;

Results:
Name|Sex|Age|Height|Weight
Alfred|M|14|69|112.5
Alice|F||56.5|84
Barbara|F||65.3|98
Carol|F||62.8|102.5
Henry|M|14|63.5|102.5
James|M|12|57.3|83
Jane|F||59.8|84.5
Janet|F||62.5|112.5
Jeffrey|M|13|62.5|84
John|M|12|59|99.5
Joyce|F||51.3|50.5
Judy|F||64.3|90
Louise|F||56.3|77
Mary|F||66.5|112
Philip|M|16|72|150
Robert|M|12|64.8|128
Ronald|M|15|67|133
Thomas|M|11|57.5|85
William|M|15|66.5|112

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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