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

Hi,

 

I have compressed the following - "Box 0f 6 widgets" to give me "6" in a separate column.

 

Now I want to multiply this number with average price but the calcs give me an error "need a numercial value to use * multiplication".

 

Anyway to fix it?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

@Nikhil28 Please try harder.

You removed the semi-colon when transforming my generic statement into a SQL variable formula. 

You also need to remove the value assignment syntax to build your SQL query

SELECT  input( COMPRESS(t1.NON_WAREHOUSE_UOM, ,'dk') , 32.)  AS CALCULATION

You obviously know how to write SQL, so please don't ask us to guide you through each baby step.  🙂

View solution in original post

8 REPLIES 8
novinosrin
Tourmaline | Level 20

Can you post the sample of your data,code, log and the desired output plz

ChrisNZ
Tourmaline | Level 20

Instead of something like

  STR= compress( VAR,,'dk');

that you must have right now, use

  NUM= input( compress( VAR,,'dk'), 32.);

to create a numeric variable.

 

 

novinosrin
Tourmaline | Level 20

Sir @ChrisNZ nice point but i would have thought autoconversion would have only resulted in a note while OP says received an error?

Nikhil28
Fluorite | Level 6

1 The SAS System 08:54 Monday, October 29, 2018

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 OPTION DEBUG=DBMS_SELECT SQL_IP_TRACE=(NOTE, SOURCE);


4 PROC SQL NOEXEC;
5 SELECT (NUM= input( COMPRESS(t1.NON_WAREHOUSE_UOM, ,'dk') , 32.)) AS CALCULATION
6 FROM WORK.QUERY_FOR_PURCHASING_0000 t1;
ERROR: The following columns were not found in the contributing tables: NUM.
7 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

8 %PUT SQL_IPTRACE_RESULT=&SYS_SQL_IP_ALL;
SQL_IPTRACE_RESULT=-1
9 OPTIONS SQL_IP_TRACE=(NONE);
10 QUIT; RUN;
11

ChrisNZ
Tourmaline | Level 20

@Nikhil28 Please try harder.

You removed the semi-colon when transforming my generic statement into a SQL variable formula. 

You also need to remove the value assignment syntax to build your SQL query

SELECT  input( COMPRESS(t1.NON_WAREHOUSE_UOM, ,'dk') , 32.)  AS CALCULATION

You obviously know how to write SQL, so please don't ask us to guide you through each baby step.  🙂

Shmuel
Garnet | Level 18

assuming the number has no decimal digits then use otherwise adapt informat

    num = input(compress(text,,'kd') , best8.);
Shmuel
Garnet | Level 18
'kd' stands for Keep Digits

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 2444 views
  • 1 like
  • 4 in conversation