DATA Step, Macro, Functions and more

how do i correct this?

Reply
Occasional Contributor
Posts: 15

how do i correct this?

[ Edited ]
1    data credit;
2    input x1-x20;
3    x1 = checking x2 = duration  x3 = history x4 = purpose x5 = amount x6 = savings  x7 = employ x8 = rate  x9 = status
                   --             --           --           --          --
                   22             22           22           22          22
3    x1 = checking x2 = duration  x3 = history x4 = purpose x5 = amount x6 = savings  x7 = employ x8 = rate  x9 = status
                                                                                      --
                                                                                      22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, (, *, **, +, -, /, ;, <, <=, <>, =, >, ><, >=, AND, EQ, GE,
              GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, [, ^=, {, |, ||, ~=.
PROC Star
Posts: 7,492

Re: how do i correct this?

What are you trying to accomplish? Hard to tell from the code you posted.

 

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 15

Re: how do i correct this?

i am using proc discim and proc factors to compute german credit datasets.

PROC Star
Posts: 7,492

Re: how do i correct this?

I'll restate my question: what were you trying to accomplish with the code you posted? e.g. I was trying to create a dataset called ZZ that had X records, each with Y variables, that contained the following values: xxx, yyy, zzz

 

Art, CEO, AnalystFinder.com

Occasional Contributor
Posts: 15

Re: how do i correct this?

i was trying to work on datasets called german credit. it contains 20 x - variables and y response variable called good_bad. my sas procedure are proc discrim and proc factors.

Super User
Posts: 7,866

Re: how do i correct this?

Sorry, but in the code you posted there is not the faintest trace of these procedures. Your code just contains a syntactically wrong datastep, the purpose of which is not clear at all.


ojoseph wrote:

i was trying to work on datasets called german credit. it contains 20 x - variables and y response variable called good_bad. my sas procedure are proc discrim and proc factors.


So, are you trying to manipulate data that is already present in a SAS dataset, or are you trying to read external (non-SAS) data into a dataset for further processing?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 15

Re: how do i correct this?

Posted in reply to KurtBremser
tying to manipulate external data into a dataset for further processing.
Super User
Posts: 19,876

Re: how do i correct this?

Please seep the following links for video tutorials for basic tasks, and the free programming course. 

 

If you're not a programmer consider using the tasks. 

 

Support.sas.com/training/tutorial

Super User
Posts: 7,866

Re: how do i correct this?

It is also very important to know your environment. Are you using SAS University Edition, or a licensed SAS installation? If it is the latter, is it single machine, or client/server? And which operating system(s) is/are involved?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,079

Re: how do i correct this?

If you just want to make your output easier to read then perhaps you just need to add a LABEL statement to your PROC call?

proc discrim data=german_credit;
  var x1-x20 ;
  label x1='Checking' x2='Duration' .... ;
run;
Super User
Posts: 7,866

Re: how do i correct this?

[ Edited ]

I see an input statement, but I see nothing that could provide data for the input (infile or cards/datalines).

Then I see several assignments to variables that were just used in the input statement, but those assignment statements are not properly separated by semicolons, and cause a syntax error message. So I have to repeat @art297's question: what are you trying to do in this data step? (Hint: your first answer to his question was not helpful at all)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,079

Re: how do i correct this?

What format is your source data? Is it a text file, like a CSV or other delimited file?

Looks like you might be trying to read variables using dummy names like X1,X2 etc and then rename to to more meaningful names.

If you want to rename the use the RENAME statement (or dataset option).

rename
  x1 = checking
  x2 = duration
  x3 = history
  x4 = purpose
  x5 = amount
  x6 = savings
  x7 = employ
  x8 = rate
  x9 = status
;

Or better just read the variable using the names you want to begin with.

data want ;
  infile 'myfile.csv' dsd truncover firstobs=2;
  input checking duration history purpose amount savings
        employ rate status
  ;
run;
Ask a Question
Discussion stats
  • 11 replies
  • 269 views
  • 1 like
  • 5 in conversation