I'm totally new to SAS, and I'm trying to understand the two attached "SAS" files I received.
The Data.txt file is a fixed-width text file, and the SAS.txt file has the column definitions.
Is there a name for these types of files in SAS? Is there a way to load them into SQL Server?
Any insight would be greatly appreciated.
Thanks!
It sounds like a source file and a skeleton program to import the data. There are no fixed names that I know of, but consider them a text source file and use the formats in the column definition to script a create table statement.
You can use an SSIS import to import a standard fixed width text file, or you could create the table in SAS, connect to SQL using an ODBC connection and upload the data.
The code in SAS to import would be something like:
data have;
infile 'path to file.txt' truncover;
INPUT
@1 PRVDR_NUM $CHAR10.
@11 SRVY_DT $CHAR8. /*YYYYMMDD*/
@19 CYC_VISIT_DT $CHAR8.
@27 CYC_VISIT_NUM 3.
@30 POC_SGN_DT $CHAR8.
@38 LSC_BLDG_CNT 2.
@40 SRVY_CMPLTN_DT $CHAR8.
;
***************************************************************;
*** SAS LABEL Statement Follows ;
***************************************************************;
LABEL
PRVDR_NUM = 'CCN'
SRVY_DT = 'Survey Date'
CYC_VISIT_DT = 'Cycle Visit Date'
CYC_VISIT_NUM = 'Cycle Visit Number'
POC_SGN_DT = 'Administrator Signed POC Date'
LSC_BLDG_CNT = 'Building Count'
SRVY_CMPLTN_DT = 'Survey Completion Date'
;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.