<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: struggling with formats used in fedsql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805332#M317227</link>
    <description>&lt;P&gt;Omit the PUT function, which always results in character:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table mkt.testa {options  replication=0 REPLACE=true } as
  select 
    a.*,
    case when b.numbasti=''
      then 0
      else 1
    end as renewed,
    b.CODOPERA_FOR,
    b.NUMBASTI_FOR   
  from public.denom a left join public.nom b
  on a.numbasti=b.numbasti
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 31 Mar 2022 15:23:50 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-31T15:23:50Z</dc:date>
    <item>
      <title>struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805270#M317199</link>
      <description>&lt;P&gt;I do not succeed in defining a numeric format in a "case when" construct in fedsql.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It gives en error in the proc summary code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: Variable RENEWED in list does not match type prescribed for this list.&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
source MPG_toyota;
create table mkt.testa {options  replication=0 REPLACE=true } as select 
a.*, case when b.numbasti='' then put(0, 3.) else put(1, 3.) end as renewed , b.CODOPERA_FOR, b.NUMBASTI_FOR   
from public.denom a left join public.nom b
on a.numbasti=b.numbasti;;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;


proc summary data=mkt.testa print ;
format _FECULVTO year. ;
class from_brand _FECULVTO ;
var renewed;
output out=test sum= mean= / autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805270#M317199</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-31T14:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805289#M317203</link>
      <description>&lt;P&gt;proc summary requires a numeric variable. open up mtk.testa dataset and verify whether renewed is char or numeric. I believe the error is how you're creating renewed in proc cas.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805289#M317203</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-03-31T14:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805304#M317211</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181158"&gt;@tarheel13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;proc summary requires a numeric variable. open up mtk.testa dataset and verify whether renewed is char or numeric. I believe the error is how you're creating renewed in proc cas.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For VAR variables. Class, By and ID variables can be character or numeric.&lt;/P&gt;
&lt;P&gt;So the variable Renewed in this code is not numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 14:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805304#M317211</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-31T14:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805329#M317225</link>
      <description>&lt;P&gt;I haven't expressed myself correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that it's not numeric therefore giving an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But HOW do I create a valid numeric variable in fedsql so that it executes correctly?&lt;/P&gt;
&lt;P&gt;If I do the same in proc sql then it runs without problems.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options casdatalimit=all;
proc sql;
create table testa  as select 
a.*, case when b.numbasti='' then 0 else 1 end as renewed , b.CODOPERA_FOR, b.NUMBASTI_FOR   
from public.denom a left join public.nom b
on a.numbasti=b.numbasti;
quit;

proc summary data=testa print ;
format _FECULVTO year. ;
class from_brand _FECULVTO ;
var renewed;
output out=test sum= mean= / autoname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 15:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805329#M317225</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-31T15:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805332#M317227</link>
      <description>&lt;P&gt;Omit the PUT function, which always results in character:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table mkt.testa {options  replication=0 REPLACE=true } as
  select 
    a.*,
    case when b.numbasti=''
      then 0
      else 1
    end as renewed,
    b.CODOPERA_FOR,
    b.NUMBASTI_FOR   
  from public.denom a left join public.nom b
  on a.numbasti=b.numbasti
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 15:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805332#M317227</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-31T15:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805335#M317229</link>
      <description>&lt;P&gt;I had tried before, it still gives error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 %studio_hide_wrapper;&lt;BR /&gt;82 proc cas;&lt;BR /&gt;83 source MPG_toyota;&lt;BR /&gt;84 create table mkt.testa {options replication=0 REPLACE=true } as&lt;BR /&gt;85 select&lt;BR /&gt;86 a.*,&lt;BR /&gt;87 case when b.numbasti=''&lt;BR /&gt;88 then 0&lt;BR /&gt;89 else 1&lt;BR /&gt;90 end as renewed,&lt;BR /&gt;91 b.CODOPERA_FOR,&lt;BR /&gt;92 b.NUMBASTI_FOR&lt;BR /&gt;93 from public.denom a left join public.nom b&lt;BR /&gt;94 on a.numbasti=b.numbasti&lt;BR /&gt;95 ;&lt;BR /&gt;96 endsource;&lt;BR /&gt;97 fedSQL.execDirect / query=MPG_toyota;&lt;BR /&gt;98 quit;&lt;BR /&gt;NOTE: Active Session now MYSESSION.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a TIMESTAMP column has been requested, but is not supported by the CASDAL driver. A DOUBLE &lt;BR /&gt;PRECISION column will be created instead. A DATETIME format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a TIMESTAMP column has been requested, but is not supported by the CASDAL driver. A DOUBLE &lt;BR /&gt;PRECISION column will be created instead. A DATETIME format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: CASDAL driver. Creation of a DATE column has been requested, but is not supported by the CASDAL driver. A DOUBLE PRECISION &lt;BR /&gt;column will be created instead. A DATE format will be associated with the column.&lt;BR /&gt;NOTE: Table TESTA was created in caslib MKT with 36688 rows returned.&lt;BR /&gt;NOTE: PROCEDURE CAS used (Total process time):&lt;BR /&gt;real time 0.75 seconds&lt;BR /&gt;cpu time 0.02 seconds&lt;BR /&gt;&lt;BR /&gt;99 &lt;BR /&gt;100 proc summary data=mkt.testa print ;&lt;BR /&gt;101 format _FECULVTO year. ;&lt;BR /&gt;102 class from_brand _FECULVTO ;&lt;BR /&gt;103 var renewed;&lt;BR /&gt;104 output out=test sum= mean= / autoname;&lt;BR /&gt;105 run;&lt;BR /&gt;NOTE: The CAS aggregation.aggregate action will be used to perform the initial summarization.&lt;BR /&gt;ERROR: The analytic variable's data type is not supported.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 15:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805335#M317229</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-31T15:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805337#M317230</link>
      <description>&lt;P&gt;Since the SQL code complains about a DATE, I think that&amp;nbsp;&lt;SPAN&gt;_FECULVTO is the culprit here.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;See if this works:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
source MPG_toyota;
create table mkt.testa {options  replication=0 REPLACE=true } as
  select 
    a.from_brand,
    year(a._FECULVTO) as FECULVTO,
    case when b.numbasti=''
      then 0
      else 1
    end as renewed,
    b.CODOPERA_FOR,
    b.NUMBASTI_FOR   
  from public.denom a left join public.nom b
  on a.numbasti=b.numbasti
;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;


proc summary data=mkt.testa print;
class from_brand FECULVTO;
var renewed;
output out=test sum= mean= / autoname;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 15:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805337#M317230</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-31T15:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805343#M317234</link>
      <description>&lt;P&gt;Thanks Kurt.&lt;/P&gt;
&lt;P&gt;But that doesn't fix it either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 15:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805343#M317234</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-31T15:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805345#M317236</link>
      <description>&lt;P&gt;What if you add a decimal point? 0.0 and 1.0 instead of 0 and 1?&lt;/P&gt;
&lt;P&gt;What if you list explicitly which variables you want instead of using SELECT *?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 16:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805345#M317236</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-31T16:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805348#M317238</link>
      <description>&lt;P&gt;Thanks Tom,&lt;/P&gt;
&lt;P&gt;I've tried selecting only a few variables and 1.0 and 0.0 instead of my then else values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The same error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I write some extra data step or select case when explicitly as character "1" and "0". This works and I use it in the class statement of the proc summary.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a strange behavior of fedsql I'd say...&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 16:10:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805348#M317238</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-03-31T16:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805361#M317243</link>
      <description>&lt;P&gt;In PROC SQL if you try to create two variables with the same name only the first one survives.&lt;/P&gt;
&lt;P&gt;Try it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
  select name , age as name
  from sashelp.class
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I assume FEDSQL will exhibit the same behavior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure that the name&amp;nbsp;&lt;STRONG&gt;renewed&lt;/STRONG&gt; has not already been used by another variable that appears before the CASE expression in your SELECT statement.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 16:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805361#M317243</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-31T16:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: struggling with formats used in fedsql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805362#M317244</link>
      <description>&lt;P&gt;Are you sure that you have actually replaced the dataset?&lt;/P&gt;
&lt;P&gt;What happens if you use a different dataset name, one that does not already exist.&lt;/P&gt;
&lt;P&gt;Do you get a different error message from the PROC SUMMARY step?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 16:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggling-with-formats-used-in-fedsql/m-p/805362#M317244</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-31T16:54:43Z</dc:date>
    </item>
  </channel>
</rss>

