DATA Step, Macro, Functions and more

How to open .sas7bdat in SAS and export to excel?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How to open .sas7bdat in SAS and export to excel?

I am quite new to SAS. I have got a file with file extension .sas7bdat which contains daily stocks prices and percentage changes. It has almost 2 million line items. I know that I can simply double click the file and open it with SAS 9.4. But, I am looking for codes which I can type in Editor and open this file. Please help me.

 

After I open this file, I need to export it to excel. Since it has 2 million data, I can not export everything in a single excel tab. So, What I want to do it randomly pick (say 10,000 or 20,000) data and export only this randomly picked data to excel.

My .sas7bdat file is on desktop.

Please help.


Accepted Solutions
Solution
‎05-03-2018 06:52 AM
Super User
Super User
Posts: 9,427

Re: How to open .sas7bdat in SAS and export to excel?

Something like:

libname tmp "c:/temp";

proc surveyselect data=tmp.stockprices
   method=srs n=10000 out=sample;
run;

proc export data=sample outfile="c:/temp/want.xlsx";
run;

View solution in original post


All Replies
Super User
Super User
Posts: 9,427

Re: How to open .sas7bdat in SAS and export to excel?

You should really look through the SAS online help videos and such like and learn SAS, as this is a step 1 learning question.  You point what is called a library reference to a folder which contains .sas7bdat files, then refer to the library and dataset name.  For instance if I had saved in c:/temp that file:

libname tmp "c:/temp";

proc export data=tmp.stockprices outfile="c:/temp/want.xlsx";
run;

http://video.sas.com/category/videos/how-to-tutorials

New Contributor
Posts: 3

Re: How to open .sas7bdat in SAS and export to excel?

But, if I have 2 million rows in that SAS file, how can I export to excel which allows only around 1 millions rows in a tab?
Super User
Super User
Posts: 9,427

Re: How to open .sas7bdat in SAS and export to excel?

You can't, if Excel has limits then that is the limit for that file.  Split the data, or use a better format for your data.  Obviously depends on what the data is for, not much point creating a report with 2mill records, so I assume this is for data transfer?  If so use CSV, plain text delimited format, can have unlimited rows, and can easily be read by the receiving party.

New Contributor
Posts: 3

Re: How to open .sas7bdat in SAS and export to excel?

Thanks. If you had read my first question completely, there you could read, "So, What I want to do it randomly pick (say 10,000 or 20,000) data and export only this randomly picked data to excel.". Any thoughts?
Solution
‎05-03-2018 06:52 AM
Super User
Super User
Posts: 9,427

Re: How to open .sas7bdat in SAS and export to excel?

Something like:

libname tmp "c:/temp";

proc surveyselect data=tmp.stockprices
   method=srs n=10000 out=sample;
run;

proc export data=sample outfile="c:/temp/want.xlsx";
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 174 views
  • 0 likes
  • 2 in conversation