BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhca60
Quartz | Level 8

pcpNPI is a numeric 20 variable but i'm getting an error for some reason:

    
454        proc sql;
455        create table ppp
456        as select
457        a.pid,
458        a.input(pcpNPI, 20.) format=20. as pcpNPI2,
                  _        __
                  79       22
                           76
ERROR 79-322: Expecting a FROM.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, CONNECTION, DICTIONARY.  

ERROR 76-322: Syntax error, statement will be ignored.

459        a.pname,
460        a.group,
461        b.nflg,
462        b.dflg,
463        b.cond,
464        b.days
465        from ftable as A
466        inner join numerator1 as B
467        on a.pid=b.pid
468        where pcpNPI2 in ('444', '444','444','444','444','444',
469        '44','44','44','444','444');
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
470        run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If variable pcpNPI is numeric, then you would not use INPUT here. You may want to use PUT, or just eliminate the function entirely and use

 

a.pcpNPI format=20. as pcpNPI2
--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

How about this:

 

input(a.pcpNPI, 20.) format=20. as pcpNPI2,
--
Paige Miller
bhca60
Quartz | Level 8

I did what you requested but still getting an error:

proc sql;
24 create table pp
25 as select
26 a.pid,
27 input(a.pcpNPI, 20.) format=20. as pcpNPI2,

ERROR: INPUT function requires a character argument.
ERROR: Character expression requires a character format.
ERROR: INPUT function requires a character argument.
ERROR: Character expression requires a character format.
ERROR: The following columns were not found in the contributing tables: pcpNPI2.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
44 run;
bhca60
Quartz | Level 8
Its actually Numeric with len 8 and format 20.
PaigeMiller
Diamond | Level 26

If variable pcpNPI is numeric, then you would not use INPUT here. You may want to use PUT, or just eliminate the function entirely and use

 

a.pcpNPI format=20. as pcpNPI2
--
Paige Miller
Tom
Super User Tom
Super User

@bhca60 wrote:
Its actually Numeric with len 8 and format 20.

What types of values does it hold? SAS cannot store 20 digit numbers exactly.

If this is some type of identifier then you should switch it to character, but you would need to do that BEFORE if becomes  a number in SAS.  So if you are reading it from a text file, like a CSV file, then read it as character to start with.  If it is coming from an external database (like ORACLE) then convert it to a character string in that database before puling it into a SAS dataset.

 

If it is actually a number then just realize that it will not be accurate to all 20 decimal places.  That should not matter for most things.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 780 views
  • 1 like
  • 3 in conversation