BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tiara19
Fluorite | Level 6

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! 🙂 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

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

View solution in original post

8 REPLIES 8
SASKiwi
PROC Star

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
Fluorite | Level 6
SASKiwi,

Okay, you've given me something to think about here. I thought LSD_MATH was
the name of the library it would go to, when I give the "Out" Command. How
do I ensure in the code that it goes to my LSD_MATH library? The
assignment says they have to go to that library together.

Forgive me, I'm sooo new with SAS- Very much appreciate a quick response 🙂
SASKiwi
PROC Star

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

ed_sas_member
Meteorite | Level 14

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*/

 

 

chaatak
Fluorite | Level 6

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;
tiara19
Fluorite | Level 6

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!

Reeza
Super User

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!


 

tiara19
Fluorite | Level 6

Thank you Reeza! It probably just feels that way because I get so lost sometimes 🙂 I'll check out those courses. Thanks.

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
  • 8 replies
  • 1609 views
  • 5 likes
  • 5 in conversation