02-06-2016 04:42 PM
I created a library called mydata, how do I import data into it so I can start running analyses? (Also, why is this so hard?) OK, don't need to answer that second question. I'm using SAS University, so are there some limitations I'm bumping against -- maybe it does not allow data to be read into it?
Thanks. New User. Previously used another stats system where this was, well, astonishingly easy, but my school has urged me to use SAS, and so I'm stuck on these basic things.
02-06-2016 06:25 PM
Okay let us suppose that you have a data set and you added it to the shared folder, so you can see it under the "Server Files And Folders" directly or under another folder.
Then you can use proc import to import your data to your library like _suppose your new data is CSV file and its name is data1_:
proc import datafile="/folders/myfolders/data1.csv" out=mydata.data1 dbms=csv replace; getnames=no; run;
You need to specify your data file name in the datafile parameters. Then specify your library name in the out parameters with the name you choose for your data.
Hope that help.
Also if you do not like to write the code each time you import new data. You can use import data option in SAS Studio and then edit the code by your library name.
02-06-2016 07:01 PM
Thanks. When I tried suggested code:
02-06-2016 08:28 PM
02-06-2016 09:11 PM
"Test" is the name of my data file, so I'm pretty sure I can't remove it and actually access the file, because then my code would not have the name of the file it is tyring to access.
I actually figured out a work-around: 1) Import CSV file into My Folders (easy); 2) Under Output Data select Change button; 3) Save As allows you to save file in Work folder in Libraries with distinct name; 4) Run statistics from table in Work folder.
I realize that this will need to be done each time since Work is a temporary folder, but after 5 hours of trying to figure out how to upload a CSV file, it's nice to run some numbers from my data.
If anyone has a solution to my original problem, how to actualy get a CSV File into the Library, I'm listening, but for now I'm OK to run my numbers this way. And again, why does this take more than 30 seconds to figure out?
02-06-2016 10:29 PM
1. Assign a library - in SAS a library is a directory that you can use to save files. You reference data sets via LIBNAME.DATASETNAME. If you assign the libname by clicking the cabinet icon under Server/Folders you can select an option for the library to stay assigned between sessions of SAS UE. Otherwise you can add the relevant line to your code each time.
libname mylib '/folders/myfolders';
2. Import your CSV to SAS dataset.
proc import out=mylib.mydata datafile='/folders/myfolders/test.csv' dbms=CSV replace; run;
3. Data set is in the library - permanently. If you want to reference it in future programs, assign the libname and go to town.
proc print data=mylib.mydata; run;
4. Your file is ready for analysis in procs
proc freq data=mylib.mydata; table _all_; run; proc means data=mylib.mydata; run;