DATA Step, Macro, Functions and more

making a sas7bdat file

Reply
Contributor
Posts: 44

making a sas7bdat file

Hello,

 

I'm using sas 9.4 full edition via a server.  I have merged multiple excel files and can see in explorer that I have the dataset that I want. However, I'm having trouble making a sas7bdat file from which to do my analyses going forward.  Does anyone have generic code for this?

 

Thanks!

Super User
Posts: 23,308

Re: making a sas7bdat file

If you've uploaded your data to the server or imported it, then you've created a SAS7BDAT file.

 

You can create a permanent data set by saving it to a library.

 

libname myfolder 'path to my folders';

proc copy in=work out=myfolder;
select myData;
run;quit;

proc print data=myfolder.myData;
run;
Contributor
Posts: 44

Re: making a sas7bdat file

Does the term "myfolder" have to be a compound name. The name of my merged data is finalfile but SAS gives me an error saying that's not a valid SAS name.  Also, do I use this same name for the 'myData' term?

 

Thanks!

Super User
Posts: 23,308

Re: making a sas7bdat file


lmyers2 wrote:

Does the term "myfolder" have to be a compound name. T


myfolder is a library name that is 8 characters or less. 

It is essentially a shortcut to a folder or location where you can save data, ie a folder on your computer. You can call it whatever you want and it has no relation to the data set name.

 


 

Thanks!


Also, do I use this same name for the 'myData' term?

 

This would be the finalfile name.

I would recommend you name it something more descriptive however.

Super User
Posts: 13,332

Re: making a sas7bdat file

When you have an error copy the log with the code and the error message and paste into a code box opened using the forum's {i} menu icon. The code box is important to preserve the message formatting as error messages often have a positional underscore character indicating the error location and the main message windows will reformat text making that diagnostic tool unavailable.

Also, it really really does help to post the code of what your are attempting so we can identify the actual cause.

You might just have the file and fileref that SAS uses in the wrong order or similar.

Contributor
Posts: 44

Re: making a sas7bdat file

Thanks so much for the help. Because I'm on a virtual desktop, I can't copy paste between virtual and where I can access my email. However, I attached a screenshot with the code and error log.  The error says that finalfile is not valid even though that's the name of the dataset to read n. 

 

NOTE: Libref FINAL was successfully assigned as follows:
      Engine:        V9
      Physical Name: H:\CBS to run final analyses
441  proc copy in=finalfile out=finalfilefinally;
ERROR: "FINALFILE" is not a valid name.
ERROR: "FINALFILEFINALLY" is not a valid name.
442  select final;
443  run;
 
NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE COPY used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
 
NOTE: The SAS System stopped processing this step because of errors.
443!      quit;
 
 
libname final 'H:\CBS to run final analyses';
proc copy in=finalfile out=finalfile;
select final;
run; quit;
 
Valued Guide
Posts: 570

Re: making a sas7bdat file

When you're using Proc Copy the In and Out parameters are library names and the file(s) to be copied are specified via the select statement. So in your case Proc Copy is expecting library names called finalfile (9 characters) and finalfilefinally (16 characters) but as @Reeza said library names are limited to 8 characters so that is why you are getting the "not a valid name error". Of course the libraries can't be declared either so you'll need to use shorter library names.

Super User
Posts: 23,308

Re: making a sas7bdat file

IN and OUT are library references not data set names. The SELECT statement has the data set name

 

 

PROC COPY IN=<input library name> OUT=<output library name>;
SELECT <list of your data sets here, if empty all are copied>;
run;
quit;

 

Replace the components with the <> with your library/data set names. 

Ask a Question
Discussion stats
  • 7 replies
  • 292 views
  • 0 likes
  • 4 in conversation