BookmarkSubscribeRSS Feed
lmyers2
Obsidian | Level 7

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!

7 REPLIES 7
Reeza
Super User

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;
lmyers2
Obsidian | Level 7

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!

Reeza
Super User

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

ballardw
Super User

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.

lmyers2
Obsidian | Level 7

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;
 
ChrisBrooks
Ammonite | Level 13

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.

Reeza
Super User

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. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 7 replies
  • 13914 views
  • 0 likes
  • 4 in conversation