DATA Step, Macro, Functions and more

Getting error while using COMPBL SAS Function

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Getting error while using COMPBL SAS Function

[ Edited ]

Hi,

While running this program , i am getting an error can any body help me out.

I am working on SAS9.1 version.

 

Code -:

 

Data char;
Input Name $ 1-50 ;
Cards;
Sandy David
Annie Watson
Hello ladies and gentlemen
Hi, I am good
;
char= compbl(Name);
Run;

 

Error :

char1 = compbl(Name);
-----
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Can anybody help me out.

 

Thanks!


Accepted Solutions
Solution
‎04-04-2017 02:19 PM
Super User
Super User
Posts: 7,988

Re: Getting error while using COMPBL SAS Function

Posted in reply to riteshkumarrai

All Replies
PROC Star
Posts: 307

Re: Getting error while using COMPBL SAS Function

Posted in reply to riteshkumarrai

Your char = ... should come before the cards statement, not after.

Super User
Posts: 5,516

Re: Getting error while using COMPBL SAS Function

Posted in reply to riteshkumarrai

It isn't the COMPBL function ... it's where you are trying to use it.

 

Any data manipulation statements should go between the INPUT statement and the CARDS statement.  You just put it in the wrong place.

New Contributor
Posts: 2

Re: Getting error while using COMPBL SAS Function

Posted in reply to Astounding

Why it doesn't work when we use after cards??

Solution
‎04-04-2017 02:19 PM
Super User
Super User
Posts: 7,988

Re: Getting error while using COMPBL SAS Function

Posted in reply to riteshkumarrai

Reading the manual is always informative:

https://v8doc.sas.com/sashtml/lgref/z0188182.htm

Super User
Posts: 5,516

Re: Getting error while using COMPBL SAS Function

Posted in reply to riteshkumarrai

SAS executes one DATA or PROC step at a time.  To do this, it needs to determine when one step ends and the next one begins.  Most of the time, a RUN; statement tells SAS that the current step is complete.  However, a CARDS; statement also has that purpose within a DATA step.  It tells SAS that it already has all the statements that are part of the DATA step, and that the data to read in will follow.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 183 views
  • 2 likes
  • 4 in conversation