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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 20407 views
  • 0 likes
  • 2 in conversation