Macro variable is not printing the table value but instead the column name

Christoffer

I want to assign these table values to macro variables:

Table values

This is how I assign the table value to the macro variable:

PROC SQL;
   CREATE TABLE Format_YYYYMM_tbl AS 
   SELECT t1.str_perdag_SAS_default FORMAT=YYMMN6. AS Format_YYYYMM,
          ("'"!!put(t1.str_perdag_SAS_default, YYMMN6.)!!"'") AS Format_YYYYMM_quo
      FROM DATOSTAMP t1;
QUIT;

PROC SQL NOPRINT;
SELECT DISTINCT 
          Format_YYYYMM,
          Format_YYYYMM_quo
          
INTO      :Format_YYYYMM,
          :Format_YYYYMM_quo
 
FROM Format_YYYYMM_tbl;

QUIT;

The issue is when I print the values in the log i get the following and not the value in the table:

49         %put Format_YYYYMM_quo;
Format_YYYYMM_quo
50         %put Format_YYYYMM;
Format_YYYYMM 

What am I doing wrong? I hope you can point me in the right direction.

Tom

Your %PUT statement is NOT trying to show the value of the macro variables. To reference the value of a macro variable use & before the name of the macro variable.

%put &Format_YYYYMM_quo;

In the %PUT statement only you can use a special syntax that will print both the name and the value separated by an =.

%put &=Format_YYYYMM &=Format_YYYYMM_quo;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Lua puts of variable name instead of variable value in table

Referring to a formattable table's column number instead of variable name

Use variable instead of data table column name reference in sum

Instead of 'table variable+column name =' is there any method to simplify that?

Expand macro value in the variable name

Table name as a value in column

How to suppress printing variable name while printing its value in sqlplus?

Looking for a macro to expand a variable to the name + value

How to get both name and value of variable in a macro?

Get column name instead of column value

Assigning a function to the value of a variable instead of the variable name

Avoid printing table name in column name while using beeline

Variable value as column name in Snowflake

C Macro get token value instead of token name

selectizeinput reading column-name instead of value

Sql: Query returns column name instead of Value

MySQL returns the name of the column instead of the value

display variable name instead of value in foreach loop

Indirect expansion returns variable name instead of value

Python get variable name instead of value

Prolog returns variable name instead of value

Make column name the variable name and assign the value of the column to that variable

Get the value of a column when column name is in a variable

Join table using column value as table name

refering to a transposed column name which is referenced by a macro variable

use variable name instead of column name in R function

Assign a variable column name in data.table

Operations on data table with variable column name

Store a table column name as variable in sql server