BookmarkSubscribeRSS Feed
TDaimee
Calcite | Level 5

To whom it may concern:

 

I am a new student to SAS, taking my first SAS class.  I had a simple assignment to import an excel file into my library and run some summary statistics.  However, when I import my file and run summary statistics, the attached error is illustrated.  When I code it, then the only statistics which is shown is the number of observations as opposed to mean, standard deviation, etc.  My theory is that the dataset which is only two columns (year and GDP) is taking the numerical data and identifying this as a character as to why I am not able to run data summary statistics.

 

Please advise, thanks!

7 REPLIES 7
ballardw
Super User

@TDaimee wrote:

To whom it may concern:

 

I am a new student to SAS, taking my first SAS class.  I had a simple assignment to import an excel file into my library and run some summary statistics.  However, when I import my file and run summary statistics, the attached error is illustrated.  When I code it, then the only statistics which is shown is the number of observations as opposed to mean, standard deviation, etc.  My theory is that the dataset which is only two columns (year and GDP) is taking the numerical data and identifying this as a character as to why I am not able to run data summary statistics.

 

Please advise, thanks!


Run Proc Contents on the data set which is one way of identifying the variable types.

 

Proc contents data=youdatasetnamegoeshere;

run;

 

If the table shows type CHAR then you likely have an issue.

 

Can you show the CODE used to read the data? Also if you could share the source file we may have specific suggestions.

 

BTW any attachment you attempted didn't make it.

 

 

TDaimee
Calcite | Level 5

Hello!

 

Yes, the following two codes is what I used to import the data and then run the data statistics:

 

/* Import data */

PROC IMPORT OUT=myData

DATAFILE = "Your_File_Path/Week_8_Assignment_1.xlsx" dbms = xlsx replace;

RUN;

 

Running statistics:

 

/* Get descriptive statistics */

PROC MEANS DATA=myData;

RUN;

 

TDaimee
Calcite | Level 5

Hi Kurt,

 

I made the following code below as well as the following 180 error as shown at the bottom of the code:

 

/* Import data */
PROC IMPORT OUT=myData DATAFILE = "/folders/myshortcuts/MyFolders/MIS445_FRED-real_GDP.xlsx" dbms = xlsx replace;
class observation_date;
var GDP;
RUN;

 

LOG Below:

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 /* Import data */
74 PROC IMPORT OUT=myData DATAFILE = "/folders/myshortcuts/MyFolders/MIS445_FRED-real_GDP.xlsx" dbms = xlsx replace;
NOTE: The previous statement has been deleted.
NOTE: The previous statement has been deleted.
75 class observation_date;
_____
180
76 var GDP;
___
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

77 RUN;

NOTE: Variable Name Change. FRED Graph Observations -> FRED_Graph_Observations
NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with
options MSGLEVEL=I.
NOTE: The import data set has 295 observations and 2 variables.
NOTE: WORK.MYDATA data set was successfully created.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds

78
79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
91

Tom
Super User Tom
Super User

PROC IMPORT does to have any statements named CLASS or VAR.  That is what the error message is telling you.

What PROC were you trying to run?

Tom
Super User Tom
Super User

 My theory is that the dataset which is only two columns (year and GDP) is taking the numerical data and identifying this as a character as to why I am not able to run data summary statistics.

When reading a spreadsheet SAS must choose (guess) at a consistent type to use for the variable that contains all of the spreadsheet cells in a single column.  If the column contains a mix of numeric and character values then it will be defined as character (you can convert a number into a character representation, but not the reverse).

 

Most likely you need to clean you your spreadsheet first.  It might be as simple as removing any extra header rows so that there is just one header row with the variable names.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 933 views
  • 0 likes
  • 4 in conversation