Hi!
I am working on a homework assignment and I'm supposed to import two files into the same SAS Library. When I write out the code, only one of the datasets imports (either the LSD csv file or the MATH file but not both). What am I doing wrong?
After I figure this out, the next step is to merge the two datasets into a single data set, but I'm just stuck on the above step! Thanks for your help. Here's my code:
proc import
datafile = "/folders/myfolders/LSD.csv"
/*folder/myfolders*/
out = LSD_MATH
dbms = csv
replace;
run;
and the other:
proc import
datafile = "/folders/myfolders/Math.csv"
/*folder/myfolders*/
out = LSD_MATH
dbms = csv
replace;
run;
I've also tried running them in the same "program" and in different ones. It still doesn't work. Please help! 🙂
@tiara19 - If you have an LSD_MATH library then specify LSD_MATH.Want1 and LSD_MATH.Want2 to output to two datasets WANT1 and WANT2 in the LSD_MATH library.
Looks like you are writing both CSV files to the same output SAS dataset - LSD_MATH - so the second import overwrites the first. Change the name of your first or second dataset to fix this.
@tiara19 - If you have an LSD_MATH library then specify LSD_MATH.Want1 and LSD_MATH.Want2 to output to two datasets WANT1 and WANT2 in the LSD_MATH library.
Hi @tiara19 ,
so you can write something like this:
proc import datafile = "/folders/myfolders/LSD.csv" /*folder/myfolders*/
out = LSD_MATH.want1 /*LDS_MATH = name of the library, want1 = name of the dataset*/
dbms = csv
replace;
run;
proc import datafile = "/folders/myfolders/Math.csv" /*folder/myfolders*/
out = LSD_MATH.want2/*LDS_MATH = name of the library, want2 = name of the dataset*/
dbms = csv
replace; run;
If you want to store your datasets permanently in a physical folder (not only in the temporary work library), be sure that you have correctly referenced your library before writing the code above.
Libname LSD_MATH "path"; /*specify the path to store permanently both datasets*/
First, you create a library named LSD_MATH:
libname LSD_MATH "/folders/myfolders/";
Then we can import both the datasets into that library:
proc import datafile = "/folders/myfolders/LSD.csv" out = LSD_MATH.LSD dbms = csv replace; getnames = yes; run; proc import datafile = "/folders/myfolders/MATH.csv" out = LSD_MATH.MATH dbms = csv replace; getnames = yes; run;
Hey guys,
THANK YOU both so much for your help! That is exactly what I needed. Funny how such a small detail can be so hard to figure out. I was able to work through the rest of the assignment pretty quickly after that. THANK YOU!!
I have been struggling because it appears SAS University for Mac is different than others (i'm not sure my teacher or my textbook understand the different nuances) - is there a good tutorial or book on SAS Programming specifically for SAS U for IOS? Thanks again!
That’s not quite correct, SAS UE is similar to a server installation of SAS, whether it’s EG or Base. The primary difference between these has to do with using an application that’s not local so you need to have that computer (server/UE) see your computer, which is accomplished via shared folders. The path that the SAS server sees is different than your local machine, ie
SAS UE - /folders/myfolders
Your computer C:\users\tiara19\SASUniversityEdition\myfolders
or Max equivalent
those are both the same location.
Besides that, the method and syntax for code is the same.
FYI - I currently use SAS UE on my Macbook at home and use SAS on desktop at work. Other than changing the file paths for the code, the same code will work fine on both systems.
If you’d like to learn about SAS there’s two free ecourses, but it’s not different beyond the myfolders issues.
@tiara19 wrote:
Hey guys,
THANK YOU both so much for your help! That is exactly what I needed. Funny how such a small detail can be so hard to figure out. I was able to work through the rest of the assignment pretty quickly after that. THANK YOU!!
I have been struggling because it appears SAS University for Mac is different than others (i'm not sure my teacher or my textbook understand the different nuances) - is there a good tutorial or book on SAS Programming specifically for SAS U for IOS? Thanks again!
Thank you Reeza! It probably just feels that way because I get so lost sometimes 🙂 I'll check out those courses. Thanks.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.