BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sergi213
Calcite | Level 5

Hi!

 

I am very new to using SAS and my only reason here is because I would love to convert a ".sas7bdat" file into a ".csv" file. I have the online university version of SAS and I have upload the ".sas7bdat" file into the server. How should I write a code that transforms the SAS file into a csv so that it can be open-source format?

 

Thank you very much,

Sergi

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

If you uploaded a file (say, xxx.sas7bdat) to your "Home" folder in SAS Studio, this file resides in your personal home directory on the server.

Right-click on "Home", select Properties, and copy the path name.

Then run this:

libname home "<insert the path name here>";

proc export
  data=home.xxx
  file="~/xxx.csv"
  dbms=csv
  replace
;
run;

You should see the newly created file in your Home, from where you can download it.

 

If this does not work, post the complete log by copy/pasting it into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

View solution in original post

6 REPLIES 6
Kurt_Bremser
Super User

If you uploaded a file (say, xxx.sas7bdat) to your "Home" folder in SAS Studio, this file resides in your personal home directory on the server.

Right-click on "Home", select Properties, and copy the path name.

Then run this:

libname home "<insert the path name here>";

proc export
  data=home.xxx
  file="~/xxx.csv"
  dbms=csv
  replace
;
run;

You should see the newly created file in your Home, from where you can download it.

 

If this does not work, post the complete log by copy/pasting it into a window opened with this button:

Bildschirmfoto 2020-04-07 um 08.32.59.jpg

sergi213
Calcite | Level 5

Dear Kurt,

 

Unfortunately it is not working. This is the log file:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         
 70         libname home "/home/u61281042/sasuser.v94;
 71         
 72         proc export
 73           data=home.epcg10
 74           file="~/epcg10.csv"
 75           dbms=csv
 76           replace
 77         ;
 78         run;
 79         
 74           file="~/epcg10.csv"
                    _
                    22
 ERROR 22-7: Invalid option name ~.
 
 80         
 81         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 82         ODS HTML CLOSE;
 83         &GRAPHTERM; ;*';*";
 ERROR: Libref HOME is not assigned.
 ERROR: Error in the LIBNAME statement.
 83       !                    */;RUN;QUIT;
 84         QUIT;RUN;
 85         ODS HTML5 (ID=WEB) CLOSE;
 86         
 87         FILENAME _GSFNAME;
 NOTE: Fileref _GSFNAME has been deassigned.
 88         DATA _NULL_;
 89         RUN;
 
 NOTE: DATA statement ha utilizado (Tiempo de proceso total):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              459.96k
       OS Memory           24488.00k
       Timestamp           07/04/2022 10:35:14 a.m.
       Step Count                        80  Switch Count  0
       Page Faults                       0
       Page Reclaims                     24
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 90         OPTIONS NOTES STIMER SOURCE SYNTAXCHECK;
 91         

Thank you very much for the help.

ballardw
Super User

This

 70         libname home "/home/u61281042/sasuser.v94;   <=missing the closing "
 71         
 72         proc export
 73           data=home.epcg10
 74           file="~/epcg10.csv"  <= so on this line the first " ends the path for the LIBNAME abvoe and the ~ is treated as a LIBNAME option
 75           dbms=csv
 76           replace
 77         ;
 78         run;
 79         
 74           file="~/epcg10.csv"
dexcort2020
Obsidian | Level 7
address home "<insert the path name here>";

pro export
  data=home.xxx
  file="~/xxx.csv"
  dbms=csv
  filename-dexter-.***
;
run;
Kurt_Bremser
Super User

ADDRESS is not a valid SAS statement, neither is PRO. Take care when you post code.

 


@dexcort2020 wrote:
address home "<insert the path name here>";

pro export
  data=home.xxx
  file="~/xxx.csv"
  dbms=csv
  filename-dexter-.***
;
run;