<?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 User-defined format not working in proc sql in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642113#M21852</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to regroup my data using various formats that I already created. However, when I put it in my proc sql code, the formats just didn't seem to work. The log shows nothing wrong when I ran the formats and the sql code and the sql code produced results with no problem (just not formatted the way i want...) I can't quite figure out what I did wrong and hope someone could provide some feedbacks!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname FORMAT '/folders/myshortcuts/myFolder';
Proc format lib=FORMAT;
value SPDlevel 1= "4"
			   2= "3"
			   3= "2"
			   4= "1"
			   5= "0"
			   .="missing"
			   other= "missing"
;
run;

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;
value race 5="missing";
run;		   

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;			   
value SPDgroup 0-12= "0"
			   13-high= "1"
			   .="missing"
			   other="missing"
;
run;

Proc sql;
create table work.adult2010 as 
select Sex,
cat(RECTYPE, SRVY_YR, HHX, FMX,FPX) as ID,
AGE_P as AgeGroup format=agegroup.,
RACERPI2 as Race format=race.,
SAD as SAD format=SPDlevel.,
NERVOUS as NERVOUS format=SPDlevel.,
RESTLESS as RESTLESS format=SPDlevel.,
HOPELESS as HOPELESS format=SPDlevel.,
EFFORT as EFFORT format=SPDlevel., 
WORTHLS as WORTHLS format=SPDlevel.,
sum(SAD, NERVOUS,RESTLESS, HOPELESS,EFFORT,WORTHLS) as K6SUM,
calculated K6SUM as SPD format=SPDgroup.
from new.adult2010;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Apr 2020 22:39:38 GMT</pubDate>
    <dc:creator>cheungmonica</dc:creator>
    <dc:date>2020-04-22T22:39:38Z</dc:date>
    <item>
      <title>User-defined format not working in proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642113#M21852</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to regroup my data using various formats that I already created. However, when I put it in my proc sql code, the formats just didn't seem to work. The log shows nothing wrong when I ran the formats and the sql code and the sql code produced results with no problem (just not formatted the way i want...) I can't quite figure out what I did wrong and hope someone could provide some feedbacks!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname FORMAT '/folders/myshortcuts/myFolder';
Proc format lib=FORMAT;
value SPDlevel 1= "4"
			   2= "3"
			   3= "2"
			   4= "1"
			   5= "0"
			   .="missing"
			   other= "missing"
;
run;

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;
value race 5="missing";
run;		   

Libname FORMAT '/folders/myshortcuts/myFolder';
proc format lib=FORMAT;			   
value SPDgroup 0-12= "0"
			   13-high= "1"
			   .="missing"
			   other="missing"
;
run;

Proc sql;
create table work.adult2010 as 
select Sex,
cat(RECTYPE, SRVY_YR, HHX, FMX,FPX) as ID,
AGE_P as AgeGroup format=agegroup.,
RACERPI2 as Race format=race.,
SAD as SAD format=SPDlevel.,
NERVOUS as NERVOUS format=SPDlevel.,
RESTLESS as RESTLESS format=SPDlevel.,
HOPELESS as HOPELESS format=SPDlevel.,
EFFORT as EFFORT format=SPDlevel., 
WORTHLS as WORTHLS format=SPDlevel.,
sum(SAD, NERVOUS,RESTLESS, HOPELESS,EFFORT,WORTHLS) as K6SUM,
calculated K6SUM as SPD format=SPDgroup.
from new.adult2010;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Apr 2020 22:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642113#M21852</guid>
      <dc:creator>cheungmonica</dc:creator>
      <dc:date>2020-04-22T22:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined format not working in proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642115#M21853</link>
      <description>&lt;P&gt;You are missing the FMTSEARCH option to tell SAS where to pick up your new formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options fmtsearch = (WORK, FORMAT, LIBRARY);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This statement tells SAS to search the libraries WORK, FORMAT and LIBRARY for a format catalog called FORMATS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW you only need one LIBNAME statement.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 22:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642115#M21853</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-04-22T22:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: User-defined format not working in proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642117#M21854</link>
      <description>Thank you so much! It worked right after that!</description>
      <pubDate>Wed, 22 Apr 2020 23:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/User-defined-format-not-working-in-proc-sql/m-p/642117#M21854</guid>
      <dc:creator>cheungmonica</dc:creator>
      <dc:date>2020-04-22T23:00:57Z</dc:date>
    </item>
  </channel>
</rss>

