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

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 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
  • 744 views
  • 0 likes
  • 2 in conversation