BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ET2
Calcite | Level 5 ET2
Calcite | Level 5

Hi there,

 

I wanted to read the dataset and in the input section, I want to use () like below

 

data student;
infile "......" delimiter=",";
input Number Height(cm) Weight(kg) ;
run;

 

but it gives me an error...

ERROR 79-322: Expecting a (.
 
ERROR 76-322: Syntax error, statement will be ignored.
 
 

How to solve this? Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

For future questions when you have any error copy from the log the entire data step or procedure code that generates the the error and on the forum open a text box using the </> icon that appears above the message window, then paste all the text from the log.

The message windows will reformat text and the SAS Log often contains diagnostic characters that will indicate where SAS found something wrong. However the reformatted text from the main message window will move those reducing the usefulness. The entire step or procedure code is because sometimes the "error" is because of missing or extra characters that appear before what SAS found as the error.

 

In this case the very most likely cause is that you are attempting to use non-standard variable names,i.e. Height(cm) Weight(kg). Standard SAS variable names can start with a letter or _ character and contain only letters, _ or digit characters and limited to 32 characters.

Change your code to read:

data student;
  infile "......" delimiter=",";
  input Number Height Weight ;
  label Height="Height(cm)"
          Weight="Weight(kg)"
  ;
run;

The label statement associates text with the variable that can be used by most procedures to provide more description about the variables and can be MUCH longer and allow most characters.

 

The specific error message you were getting is related to the () on the Input statement. SAS has some options for treating some input options as a group which uses (). However there will additional constraints and the "groups" quite often are in pairs where the first bit inside ( ) is a list of variables and the second is some instructions on how to read those variable. Since your code didn't have the second set of () right after the (cm) then the expected instructions were missing.

View solution in original post

2 REPLIES 2
ballardw
Super User

For future questions when you have any error copy from the log the entire data step or procedure code that generates the the error and on the forum open a text box using the </> icon that appears above the message window, then paste all the text from the log.

The message windows will reformat text and the SAS Log often contains diagnostic characters that will indicate where SAS found something wrong. However the reformatted text from the main message window will move those reducing the usefulness. The entire step or procedure code is because sometimes the "error" is because of missing or extra characters that appear before what SAS found as the error.

 

In this case the very most likely cause is that you are attempting to use non-standard variable names,i.e. Height(cm) Weight(kg). Standard SAS variable names can start with a letter or _ character and contain only letters, _ or digit characters and limited to 32 characters.

Change your code to read:

data student;
  infile "......" delimiter=",";
  input Number Height Weight ;
  label Height="Height(cm)"
          Weight="Weight(kg)"
  ;
run;

The label statement associates text with the variable that can be used by most procedures to provide more description about the variables and can be MUCH longer and allow most characters.

 

The specific error message you were getting is related to the () on the Input statement. SAS has some options for treating some input options as a group which uses (). However there will additional constraints and the "groups" quite often are in pairs where the first bit inside ( ) is a list of variables and the second is some instructions on how to read those variable. Since your code didn't have the second set of () right after the (cm) then the expected instructions were missing.

ET2
Calcite | Level 5 ET2
Calcite | Level 5
Thank you so much!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 2 replies
  • 597 views
  • 1 like
  • 2 in conversation