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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

NUmsf
Calcite | Level 5
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?
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

NUmsf
Calcite | Level 5
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?
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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