【发布时间】:2019-04-19 17:33:25
【问题描述】:
如果我的标题读起来令人困惑,我深表歉意,但我不知道如何简要描述它。
我试图从一个宏变量的表中调用一个变量(该表是一个宏变量)
我的宏是这样的:
%macro genre_analysis(table1=,table2=,genre=,genre1=);
proc sql;
create table &table1 as
select id, original_title, genres, revenue
from genres_revenue
where genres_revenue.genres like &genre
and revenue is not null
group by id
having revenue ne 0
;
quit;
proc sql;
create table &table2 as
select avg(revenue) as Average format=dollar16.2, median(revenue) as Median format=dollar16.2, std(revenue) as std format=dollar16.2
from &table1;
quit;
在我进入宏的这一部分之前一切正常:
proc sql;
title "Revenue Stats by Genre";
insert into genre_summary
set Genre=&genre1,
average=&table2.average,
median=&table2.median,
std=&table2.std;
%mend genre_analysis;
我正在尝试将一行插入到我在宏之外创建的表中。但是使用“&table2.average”和以“&table2”开头的其他两个不会调用我在宏中创建的表中的变量。
例如:
%genre_analysis(table1=horror_revenue,table2=horror_revenue_stats,genre='%Horror%',genre1='Horror')
返回:
NOTE: Table WORK.HORROR_REVENUE created, with 725 rows and 4 columns.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
NOTE: Table WORK.HORROR_REVENUE_STATS created, with 1 rows and 3 columns.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Character expression requires a character format.
ERROR: Character expression requires a character format.
ERROR: Character expression requires a character format.
ERROR: It is invalid to assign a character expression to a numeric value using the SET clause.
ERROR: It is invalid to assign a character expression to a numeric value using the SET clause.
ERROR: It is invalid to assign a character expression to a numeric value using the SET clause.
**ERROR: The following columns were not found in the contributing tables:
horror_revenue_statsaverage, horror_revenue_statsmedian, horror_revenue_statsstd.**
我一直专注于我主演的错误,因为我相信这就是问题所在。
我尝试使用“from”子句,但这似乎也不起作用。
任何帮助或建议将不胜感激!
【问题讨论】:
-
不知道为什么你在
insert上方有一个title -
我也是,我会删除它。