Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

Reply
Occasional Contributor
Posts: 7

Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

When I import data from an Excel spreadsheet, I am able to view table initially, but when I run a proc print or proc contents it says I only have 1 observation and 0 variables and then I am not able to view the table after that. Any suggestions?

Super User
Posts: 17,905

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

post your log

Occasional Contributor
Posts: 7

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

1    libname sasdata 'C:\Documents and Settings\D511081\Desktop\africa aids\SASData';

NOTE: Libref SASDATA was successfully assigned as follows:

      Engine:        V9

      Physical Name: C:\Documents and Settings\D511081\Desktop\africa aids\SASData

2

3    data sasdata.maindata;

NOTE: The data set SASDATA.MAINDATA has 1 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

4    proc contents data = sasdata.maindata;

5    run;

NOTE: PROCEDURE CONTENTS used (Total process time):

      real time           0.18 seconds

      cpu time            0.01 seconds

6    libname sasdata 'C:\Documents and Settings\D511081\Desktop\africa aids\SASData';

NOTE: Libref SASDATA was successfully assigned as follows:

      Engine:        V9

      Physical Name: C:\Documents and Settings\D511081\Desktop\africa aids\SASData

7

8    data sasdata;

NOTE: The data set WORK.SASDATA has 1 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.03 seconds

      cpu time            0.00 seconds

9    proc contents data = sasdata;

10   run;

NOTE: PROCEDURE CONTENTS used (Total process time):

      real time           0.15 seconds

      cpu time            0.01 seconds

libname sasdata 'C:\Documents and Settings\D511081\Desktop\africa aids\SASData';

data sasdata;

proc contents data = sasdata;

run;

Super User
Posts: 17,905

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

There's no import only a library declaration.

What does the following tell you:

proc datasets library=sasdata;

run;

Occasional Contributor
Posts: 7

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA.

NOTE: SAS (r) Proprietary Software 9.2 (TS2M3)

      Licensed to KAISER FOUNDATION HOSPITALS, Site 70064409.

NOTE: This session is executing on the XP_PRO  platform.

NOTE: SAS initialization used:

      real time           2.88 seconds

      cpu time            1.68 seconds

1    proc datasets library=sasdata;

                                              Directory

             Libref         SASDATA

             Engine         V9

             Physical Name  C:\Documents and Settings\D511081\Desktop\africa aids\SASData

             Filename       C:\Documents and Settings\D511081\Desktop\africa aids\SASData

                                    Member   File

                       #  Name      Type     Size  Last Modified

                       1  MAINDATA  DATA     5120  06May13:14:46:21

2    run;

Super User
Posts: 17,905

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

You should probably delete your site info.

Basically the libname statement tells SAS where files are stored, but there isn't anything in your indicating that there's any data there.

The line data sasdata.maindata creates that 1 variable 0 obs dataset, but doesn't do anything.

Basically, you're doing something wrong.

You need to import the data through the wizard. If you're totally new to SAS there is a built in tutorial that goes through this stuff. Go to Help>Getting Started with SAS Software and some of the tutorials on there.

Occasional Contributor
Posts: 7

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

But the dataset "MainData" does exist in the folder I declare. So I'm not sure what I'm missing here.

libname sasdata 'C:\Documents and Settings\D511081\Desktop\africa aids\SASData';

data sasdata.maindata;

set sasdata.maindata;

proc contents data=sasdata.maindata;

run;

Super User
Posts: 17,905

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

Because you created it. If it already existed before you ran the line data sasdata.maindata then you've overwritten it.

What you are looking for is:

proc contents data=sasdata.maindata;

run;

Super Contributor
Posts: 644

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

To amplify Reeza it looks like what pma85 seems to be attempting is some sort of 'declaration'  in the following code

3    data sasdata.maindata;

NOTE: The data set SASDATA.MAINDATA has 1 observations and 0 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

Unfortunately this step has destroyed the existing dataset (excel spreadsheet?) and replaced it with one having no content.

If you want to import the data from the spreadsheet into a SAS table use the set statement:

data work.maindata_copy ;

     set sasdata.maindata ;

     * other stuff - data recoding etc as required ;

run ;

Richard

Occasional Contributor
Posts: 7

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

It works now. I took out the data step and went straight to running my proc prints, proc contents etc. Thanks!

Super User
Posts: 17,905

Re: Importing Excel into SAS using wizard; not identifying variables when I use proc print/contents

You mention excel in your question, where did Excel come into play?

Ask a Question
Discussion stats
  • 10 replies
  • 252 views
  • 0 likes
  • 3 in conversation