<?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 Using Formats to Enhance My Output in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532294#M6007</link>
    <description>&lt;P&gt;Hello. Please see the code below.&amp;nbsp; I am using the SAS University Edition (SAS Studio).&amp;nbsp; I am not getting the correct output along with error messages.&amp;nbsp; The output should reflect under columns (Ques1-Ques5) "Agree", "Strongly Agree", etc.&amp;nbsp; I may be mixing apples and oranges here.&amp;nbsp; Can anybody tell me how to correct my code or show me a correct version of my code?&amp;nbsp; FYI: I am a student and following along in my book (p.59-60) in the book entitled: "Learning SAS by Example. A Programmer's Guide.&amp;nbsp; 2nd Edition"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Learn1 '/folders/myshortcuts/New_folder';
data Learn1.Test_Scores1;
input ID Gender$ Age Salary Ques1-Ques5$;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1 
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3 
007 F 45 76100 5 3 4 3 3 
;
run;

proc format;
value $Gender 'M'   = 'Male'
              'F'   = 'Female'
              ' '   = 'Not Entered'
              other = 'Miscoded';
value Age low-29  = 'Less than 30'
          30-50   = '30 to 50'
          51-high = '51+';
value $Likert '1' = 'Str Disagree'
              '2' = 'Disagree'
              '3' = 'No opinion'
              '4' = 'Agree'
              '5' = 'Str Agree';
run;

title "Data";
proc print data=Learn1.Test_Scores1;
id ID;
var Gender Age Salary Ques1-Ques5;
format Gender      $Gender.
       Age         Age.
       Ques1-Ques5 $Likert.
       Salary      Dollar11.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Errors:&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques1 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques2 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques3 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques4 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;110 run;&lt;/DIV&gt;</description>
    <pubDate>Sat, 02 Feb 2019 17:07:04 GMT</pubDate>
    <dc:creator>yautja33</dc:creator>
    <dc:date>2019-02-02T17:07:04Z</dc:date>
    <item>
      <title>Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532294#M6007</link>
      <description>&lt;P&gt;Hello. Please see the code below.&amp;nbsp; I am using the SAS University Edition (SAS Studio).&amp;nbsp; I am not getting the correct output along with error messages.&amp;nbsp; The output should reflect under columns (Ques1-Ques5) "Agree", "Strongly Agree", etc.&amp;nbsp; I may be mixing apples and oranges here.&amp;nbsp; Can anybody tell me how to correct my code or show me a correct version of my code?&amp;nbsp; FYI: I am a student and following along in my book (p.59-60) in the book entitled: "Learning SAS by Example. A Programmer's Guide.&amp;nbsp; 2nd Edition"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname Learn1 '/folders/myshortcuts/New_folder';
data Learn1.Test_Scores1;
input ID Gender$ Age Salary Ques1-Ques5$;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1 
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3 
007 F 45 76100 5 3 4 3 3 
;
run;

proc format;
value $Gender 'M'   = 'Male'
              'F'   = 'Female'
              ' '   = 'Not Entered'
              other = 'Miscoded';
value Age low-29  = 'Less than 30'
          30-50   = '30 to 50'
          51-high = '51+';
value $Likert '1' = 'Str Disagree'
              '2' = 'Disagree'
              '3' = 'No opinion'
              '4' = 'Agree'
              '5' = 'Str Agree';
run;

title "Data";
proc print data=Learn1.Test_Scores1;
id ID;
var Gender Age Salary Ques1-Ques5;
format Gender      $Gender.
       Age         Age.
       Ques1-Ques5 $Likert.
       Salary      Dollar11.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Errors:&lt;/P&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques1 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques2 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques3 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR: You are trying to use the character format $LIKERT with the numeric variable Ques4 in data set LEARN1.TEST_SCORES1.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;110 run;&lt;/DIV&gt;</description>
      <pubDate>Sat, 02 Feb 2019 17:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532294#M6007</guid>
      <dc:creator>yautja33</dc:creator>
      <dc:date>2019-02-02T17:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532299#M6008</link>
      <description>&lt;P&gt;Try this you had if you really want Ques1-5 as strings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test_Scores1;
input ID Gender$ Age Salary Ques1 $ Ques2 $ Ques3 $ Ques4 $ Ques5 $;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1 
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3 
007 F 45 76100 5 3 4 3 3 
;
run;

proc format;
value $Gender 'M'   = 'Male'
              'F'   = 'Female'
              ' '   = 'Not Entered'
              other = 'Miscoded';
value Age low-29  = 'Less than 30'
          30-50   = '30 to 50'
          51-high = '51+';
value $Likert '1' = 'Str Disagree'
              '2' = 'Disagree'
              '3' = 'No opinion'
              '4' = 'Agree'
              '5' = 'Str Agree';
run;

title "Data";
proc print data=Test_Scores1;
id ID;
var Gender Age Salary Ques1-Ques5;
format Gender      $Gender.
       Age         Age.
       Ques1-Ques5 $Likert.
       Salary      Dollar11.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;for numbers do this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Test_Scores1;
input ID Gender$ Age Salary Ques1-Ques5;
datalines;
001 M 23 28000 1 2 1 2 3
002 F 55 76123 4 5 2 1 1 
003 M 38 36500 2 2 2 2 1
004 F 67 128000 5 3 2 2 4
005 M 22 23060 3 3 3 4 2
006 M 63 90000 2 3 5 4 3 
007 F 45 76100 5 3 4 3 3 
;
run;

proc format;
value $Gender 'M'   = 'Male'
              'F'   = 'Female'
              ' '   = 'Not Entered'
              other = 'Miscoded';
value Age low-29  = 'Less than 30'
          30-50   = '30 to 50'
          51-high = '51+';
value $Likert 1 = 'Str Disagree'
              2 = 'Disagree'
              3 = 'No opinion'
              4 = 'Agree'
              5 = 'Str Agree';
run;

title "Data";
proc print data=Test_Scores1;
id ID;
var Gender Age Salary Ques1-Ques5;
format Gender      $Gender.
       Age         Age.
       Ques1-Ques5 Likert.
       Salary      Dollar11.2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 18:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532299#M6008</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-02-02T18:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532305#M6010</link>
      <description>Your LIKERT format is created as a character format, with the $, but the log is saying that Ques1-Ques5 is numeric, so you need a numeric format, not a character format.</description>
      <pubDate>Sat, 02 Feb 2019 18:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532305#M6010</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-02T18:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532313#M6013</link>
      <description>&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;It worked beautifully.&amp;nbsp; I understand what I needed to do.&lt;/P&gt;&lt;P&gt;Again, thank you.&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Sat, 02 Feb 2019 20:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/532313#M6013</guid>
      <dc:creator>yautja33</dc:creator>
      <dc:date>2019-02-02T20:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/581645#M13717</link>
      <description>&lt;P&gt;Thank you this was a great help..&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 04:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/581645#M13717</guid>
      <dc:creator>Meet_SAS</dc:creator>
      <dc:date>2019-08-16T04:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Formats to Enhance My Output</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/651738#M22417</link>
      <description>&lt;P&gt;could also just upload the data using the specified path&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Learn.Survey;&lt;BR /&gt;infile '/folders/myfolders/BookFiles/survey.txt';&lt;BR /&gt;input ID $ Gender $ Age Salary Ques1 $ Ques2 $ Ques3 $ Ques4 $ Ques5 $;&lt;BR /&gt;run;&lt;BR /&gt;/* Needed to label each Question out with the dollar sign afterwards instead of doing Ques1-Ques5, dumb */&lt;BR /&gt;proc format;&lt;BR /&gt;value $Gender 'M' = 'Male'&lt;BR /&gt;'F' = 'Female'&lt;BR /&gt;' ' = 'not listed'&lt;BR /&gt;other = 'miscoded';&lt;BR /&gt;value Age low-29 = 'below 30'&lt;BR /&gt;30-50 = '30 to 50'&lt;BR /&gt;51-high = 'above 51';&lt;BR /&gt;value $Likert '1' = 'Str Disagree'&lt;BR /&gt;'2' = 'Disagree'&lt;BR /&gt;'3' = 'No Opinion'&lt;BR /&gt;'4' = 'Agree'&lt;BR /&gt;'5' = 'Str Agree';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;title "Data Set Survey with Formatted Values";&lt;BR /&gt;proc print data = Learn.survey;&lt;BR /&gt;id ID;&lt;BR /&gt;var Gender Age Salary Ques1-Ques5;&lt;BR /&gt;format Gender $Gender.&lt;BR /&gt;Age Age.&lt;BR /&gt;Ques1-Ques5 $Likert.&lt;BR /&gt;Salary Dollar11.2;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 14:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-Formats-to-Enhance-My-Output/m-p/651738#M22417</guid>
      <dc:creator>skatethejake</dc:creator>
      <dc:date>2020-05-29T14:24:25Z</dc:date>
    </item>
  </channel>
</rss>

