Hi all,
This is a beginner's question
I am trying to merge 2 SAS datasets into one by ID with a PROC SQL, but it seems that my file reference is wrong.
The log says that my file doesn't exist.
Would anybody know what is wrong with this code?
libname ABC '/global/home/XXX';
filename K1 '/global/home/XXX.sas7bdat';
filename K2 '/global/home/XXYXX.sas7bdat';
proc sql;
select k.ID as A_BBB,
r.ID as B_BBB,
AGE , GENDER, HEIGHT, CITY , PHONE NUMBE
FROM ABC.K1 as K,
ABC.K2 as R
WHERE K.ID eq r.ID;
QUIT;
Thank you
You need a LIBNAME statement, not a FILENAME statement.
You create a reference to the folder with the files and then use them as LibName.DataSetName
Check if the following works, if not, please post your full log - you may want to check that Phone Number is spelled correctly for example. Usually you don't have spaces in the variable name as well as you're missing the R.
You probably want to replace it with: 'phone number'n or phoneNumber depending on variable name.
libname ABC '/global/home/'; proc sql; select k.ID as A_BBB, r.ID as B_BBB, AGE , GENDER, HEIGHT, CITY , PHONE NUMBE FROM ABC.K1 as K, ABC.K2 as R ON K.ID eq r.ID; QUIT;
@Dublin187 wrote:
Hi all,
This is a beginner's question
I am trying to merge 2 SAS datasets into one by ID with a PROC SQL, but it seems that my file reference is wrong.
The log says that my file doesn't exist.
Would anybody know what is wrong with this code?
libname ABC '/global/home/XXX'; filename K1 '/global/home/XXX.sas7bdat'; filename K2 '/global/home/XXYXX.sas7bdat'; proc sql; select k.ID as A_BBB, r.ID as B_BBB, AGE , GENDER, HEIGHT, CITY , PHONE NUMBE FROM ABC.K1 as K, ABC.K2 as R WHERE K.ID eq r.ID; QUIT;
Thank you
You need a LIBNAME statement, not a FILENAME statement.
You create a reference to the folder with the files and then use them as LibName.DataSetName
Check if the following works, if not, please post your full log - you may want to check that Phone Number is spelled correctly for example. Usually you don't have spaces in the variable name as well as you're missing the R.
You probably want to replace it with: 'phone number'n or phoneNumber depending on variable name.
libname ABC '/global/home/'; proc sql; select k.ID as A_BBB, r.ID as B_BBB, AGE , GENDER, HEIGHT, CITY , PHONE NUMBE FROM ABC.K1 as K, ABC.K2 as R ON K.ID eq r.ID; QUIT;
@Dublin187 wrote:
Hi all,
This is a beginner's question
I am trying to merge 2 SAS datasets into one by ID with a PROC SQL, but it seems that my file reference is wrong.
The log says that my file doesn't exist.
Would anybody know what is wrong with this code?
libname ABC '/global/home/XXX'; filename K1 '/global/home/XXX.sas7bdat'; filename K2 '/global/home/XXYXX.sas7bdat'; proc sql; select k.ID as A_BBB, r.ID as B_BBB, AGE , GENDER, HEIGHT, CITY , PHONE NUMBE FROM ABC.K1 as K, ABC.K2 as R WHERE K.ID eq r.ID; QUIT;
Thank you
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: