- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Good afternoon
I am trying to export an excel file into SAS EG and I keep getting the above mentioned error message. Can anyone assist me? This is the code I am using.
/* claims file name from AM From payer directory */
%LET claimsFile= \\Cifs2\pop_lab$\P4P\BCBSMA\FY20\Actively Managed\From BCBSMA\AMCohorts_01May2019_31Mar2020_medical.xlsx;
%LET claimsFileType= XLSX; /* Options: DLM, XLSX */
%LET claimsSheetname= AMCohorts_01May2019_31Mar2020_m;
LIBNAME EPICPAT odbc complete="driver=SQL Server; database=EPIC; server=PHSSQL2195" schema=PATIENT; /* dev server */
/*Cohort period*/
%let Beg_dt= '01MAY2019'D;
%LET End_dt = '30APR2020'D;
%LET HCPCS = hcpcs_proc_cd IN ('99281',' 99282', '99283', '99284', '99285');
%LET REV = revenue_cd IN ('450','451','452','456','459','981');
proc sql;
create table AMCohort as select
distinct *
from claimsfile.AMCohorts_01May2019_31Mar2020_medical
where &REV
and &HCPCS
;quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I presume you're trying to import that Excel file in a SAS dataset.
It looks like AMCohorts_01May2019_31Mar2020_medical.xlsx is the name of the Excel file, and AMCohorts_01May2019_31Mar2020_m is the name of the sheet/tab in the Excel file? If so, then here are two different approaches that should work for importing your Excel file:
/* Excel file: AMCohorts_01May2019_31Mar2020_medical.xlsx */
/* Sheet name: AMCohorts_01May2019_31Mar2020_m */
/* Approach 1 - using a LIBNAME */
libname clmFile xlsx 'path\AMCohorts_01May2019_31Mar2020_medical.xlsx';
/* (note that clmFile must be no longer than 8 characters for a LIBNAME) */
proc sql;
create table work.import1 as
select *
from clmFile.AMCohorts_01May2019_31Mar2020_m
;
quit;
/* Approach 2 - using PROC IMPORT*/
proc import datafile='path\AMCohorts_01May2019_31Mar2020_medical.xlsx'
out=work.import2
dbms=xlsx
replace;
sheet='AMCohorts_01May2019_31Mar2020_m';
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@wheddingsjr wrote:
Good afternoon
I am trying to export an excel file into SAS EG and I keep getting the above mentioned error message. Can anyone assist me? This is the code I am using.
/* claims file name from AM From payer directory */ %LET claimsFile= \\Cifs2\pop_lab$\P4P\BCBSMA\FY20\Actively Managed\From BCBSMA\AMCohorts_01May2019_31Mar2020_medical.xlsx; %LET claimsFileType= XLSX; /* Options: DLM, XLSX */ %LET claimsSheetname= AMCohorts_01May2019_31Mar2020_m; LIBNAME EPICPAT odbc complete="driver=SQL Server; database=EPIC; server=PHSSQL2195" schema=PATIENT; /* dev server */ /*Cohort period*/ %let Beg_dt= '01MAY2019'D; %LET End_dt = '30APR2020'D; %LET HCPCS = hcpcs_proc_cd IN ('99281',' 99282', '99283', '99284', '99285'); %LET REV = revenue_cd IN ('450','451','452','456','459','981'); proc sql; create table AMCohort as select distinct * from claimsfile.AMCohorts_01May2019_31Mar2020_medical where &REV and &HCPCS ;quit;
I do not see any code in that posted that attempts to use the XLSX file in any way.
The way you use
from claimsfile.AMCohorts_01May2019_31Mar2020_medical
is telling SAS to look for that way-too-long name AMCohorts_01May2019_31Mar2020_medical in the library named Claimsfile. Library names are limited to 8 characters, so "Claimsfile" at 10 characters is invalid, the data set names are limited to 32 characters and that at 37 characters is too long.
And if you meant to use the text in that macro variable as a data source you need to do something else to establish a link with the file. A libname statement or task to connect to the file.