BookmarkSubscribeRSS Feed
DanielEms
Calcite | Level 5

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!

1 REPLY 1
Reeza
Super User

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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 1 reply
  • 749 views
  • 0 likes
  • 2 in conversation