我正在尝试连接两个表: 表A具有三列:州,县和计数(所述县的农贸市场的数量) 表B包含几列:省,县和数个数据列(例如食物获取得分)
我正在尝试将它们的组合方式放入每个州/县组合的计数(因为有多个具有相同名称的县)以及表B的州和县以及数据列。 / p>
我一直在努力寻求SAS,试图加入合作伙伴。我在这里阅读了其他一些问题,但是我找不到我的代码中的错误所在。
PROC SQL;
CREATE TABLE WORK.QUERY1
AS
SELECT FMDV4.State, FMDV4.County, FMDV4.Count, CFSDV1.GROC14,
CFSDV1.SUPERC14, CFSDV1.CONVS14, CFSDV1.SPECS14, CFSDV1.FOODINSEC_13_15,
CFSDV1.PCT_LACCESS_POP15, CFSDV1.DIRSALES_FARMS12, CFSDV1.FMRKT16,
CFSDV1.FOODHUB16, CFSDV1.CSA12, CFSDV1.POVRATE15, CFSDV1.PERPOV10
FROM FNLPRJT.CFSDV1 AS CFSDV1
INNER JOIN FNLPRJT.FMDV4 AS FMDV4
ON (( CFSDV1.State = FMDV4.State ) AND ( CFSDV1.County =
FMDV4.County ));
QUIT;
我还尝试了一些变体,例如:
PROC SQL;
CREATE TABLE WORK.QUERY1
AS
SELECT FMDV4.State, FMDV4.County, FMDV4.Count, CFSDV1.GROC14,
CFSDV1.SUPERC14, CFSDV1.CONVS14, CFSDV1.SPECS14, CFSDV1.FOODINSEC_13_15,
CFSDV1.PCT_LACCESS_POP15, CFSDV1.DIRSALES_FARMS12, CFSDV1.FMRKT16,
CFSDV1.FOODHUB16, CFSDV1.CSA12, CFSDV1.POVRATE15, CFSDV1.PERPOV10
FROM FNLPRJT.CFSDV1 AS CFSDV1
INNER JOIN FNLPRJT.FMDV4 AS FMDV4
ON CFSDV1.State = FMDV4.State
WHERE CFSDV1.County = FMDV4.County;
QUIT;
我得到一个0行的表,其中各列应为(州,县,伯爵,)。我只是想念当当数据!谁能帮我找到我的错误吗?
答案 0 :(得分:0)
您可以尝试
propcase(CFSDV1.State) = propcase(FMDV4.State)
和
propcase(CFSDV1.County) = propcase(FMDV4.County);
如果这不起作用,请尝试使用诸如 trim 和 compress 之类的字符函数来删除数据中可能存在的所有空白。