<?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: Can we do more than one function in a single SAS macro? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823837#M35092</link>
    <description>&lt;P&gt;You can do all of this without a macro at all. Why do you feel a macro is needed?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 13:52:10 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-18T13:52:10Z</dc:date>
    <item>
      <title>Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823836#M35091</link>
      <description>&lt;P&gt;dm log 'clear';&lt;/P&gt;&lt;P&gt;libname hosp 'D:\sas';&lt;/P&gt;&lt;P&gt;data labs;&lt;BR /&gt;input id prelab1 prelab2 postlab1 postlab2;&lt;BR /&gt;datalines;&lt;BR /&gt;1 9.8 318 10.9 215&lt;BR /&gt;2 . . . 129&lt;BR /&gt;3 . . 5.7 136&lt;BR /&gt;4 7.8 124 . .&lt;BR /&gt;5 . . 6.6 123&lt;BR /&gt;6 . . . 127&lt;BR /&gt;7 . . 5.8 127&lt;BR /&gt;8 7.9 196 . .&lt;BR /&gt;9 . . 4.9 134&lt;BR /&gt;10 . . . 131&lt;BR /&gt;11 . 171 . .&lt;BR /&gt;12 7.1 140 7.1 88&lt;BR /&gt;13 . 160 . 135&lt;BR /&gt;14 6.9 107 6.5 154&lt;BR /&gt;15 . . 6.6 122&lt;BR /&gt;16 . 127 . .&lt;BR /&gt;17 6.5 102 . .&lt;BR /&gt;18 . 149 . .&lt;BR /&gt;19 . . 6.6 120&lt;BR /&gt;20 . . . 129&lt;BR /&gt;21 . 128 . .&lt;BR /&gt;22 5.5 146 5.3 136&lt;BR /&gt;23 . . 6.5 .&lt;BR /&gt;24 6.6 127 6.3 130&lt;BR /&gt;25 . 155 . 133&lt;BR /&gt;26 7 145 . .&lt;BR /&gt;27 . . 8.1 148&lt;BR /&gt;28 6.6 103 . .&lt;BR /&gt;29 6.8 140 6.5 124&lt;BR /&gt;30 . 143 . .&lt;BR /&gt;31 . . 5.7 128&lt;BR /&gt;32 6.6 156 7.2 .&lt;BR /&gt;33 . . . 140&lt;BR /&gt;34 . . . 134&lt;BR /&gt;35 . . 6.5 111&lt;BR /&gt;36 . . . 137&lt;BR /&gt;37 5.7 127 . .&lt;BR /&gt;38 . 148 6.3 142&lt;BR /&gt;39 . 173 6.8 150&lt;BR /&gt;40 5.7 163 . .&lt;BR /&gt;41 . 150 . .&lt;BR /&gt;42 . 167 . .&lt;BR /&gt;43 8.6 184 6.5 .&lt;BR /&gt;44 8.2 113 7.8 173&lt;BR /&gt;45 24 . 144 . .&lt;BR /&gt;46 . . . 126&lt;BR /&gt;47 6.5 109 6.9 115&lt;BR /&gt;48 7.7 184 7.8 190&lt;BR /&gt;49 . 158 . .&lt;BR /&gt;50 . . . 127&lt;BR /&gt;51 . 146 . .&lt;BR /&gt;52 . . 5.9 128&lt;BR /&gt;53 . 127 5.9 131&lt;BR /&gt;54 9.6 198 7 84&lt;BR /&gt;55 . . 7 93&lt;BR /&gt;56 6 133 . .&lt;BR /&gt;57 6.7 185 7.5 204&lt;BR /&gt;58 6.3 165 . 136&lt;BR /&gt;59 4.9 150 . 137&lt;BR /&gt;60 6.9 130 6.9 127&lt;BR /&gt;61 6.3 137 7.1 166&lt;BR /&gt;62 . 138 . 149&lt;BR /&gt;63 5.5 160 5.7 152&lt;BR /&gt;64 12.5 592 5.5 147&lt;BR /&gt;65 . . . 148&lt;BR /&gt;66 . . . 161&lt;BR /&gt;67 7.4 162 6.5 204&lt;BR /&gt;68 9 255 5.8 150&lt;BR /&gt;69 7.3 141 7.2 128&lt;BR /&gt;70 7.5 . 7.7 198&lt;BR /&gt;71 6.9 173 . .&lt;BR /&gt;72 . . 6.9 150&lt;BR /&gt;73 6.3 135 6.3 164&lt;BR /&gt;74 8.5 110 8.3 156&lt;BR /&gt;75 6.7 121 7 125&lt;BR /&gt;76 . . 5.7 132&lt;BR /&gt;77 . . . 154&lt;BR /&gt;78 9.6 201 8 .&lt;BR /&gt;79 . 138 . .&lt;BR /&gt;80 . 131 . .&lt;BR /&gt;81 . 183 . 141&lt;BR /&gt;82 . . . 185&lt;BR /&gt;83 6.3 145 . .&lt;BR /&gt;84 . 131 . 134&lt;BR /&gt;85 . 185 6.5 122&lt;BR /&gt;86 . . . 201&lt;BR /&gt;87 7.8 160 8.3 213&lt;BR /&gt;88 5.6 138 . .&lt;BR /&gt;89 10.9 114 8.9 178&lt;BR /&gt;90 . . 6.6 105&lt;BR /&gt;91 . . . 147&lt;BR /&gt;92 6.7 103 6 138&lt;BR /&gt;93 . . . 139&lt;BR /&gt;94 . 137 . .&lt;BR /&gt;95 . . . 134&lt;BR /&gt;96 . . 6.2 161&lt;BR /&gt;97 9 191 7.3 156&lt;BR /&gt;98 6.7 107 . .&lt;BR /&gt;99 . . 9.1 127&lt;BR /&gt;100 . . 6.6 119&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/*I have a dataset of the lab values of two tests before and after taking a certain drug. Using a single macro, I need&lt;BR /&gt;to do three things:&lt;/P&gt;&lt;P&gt;1. remove missing values for the changes in these lab values (post-pre). That is changelab1 and changelab2&lt;BR /&gt;2. classify the patients in this sample into three groups:&lt;BR /&gt;Group A: Those with prelab1 greater than or equal 6&lt;BR /&gt;Group B: Those with prelab2 greater than or equal 130&lt;BR /&gt;Group C: Those with prelab1 &amp;gt;= 6 and prelab2 &amp;gt;= 130&lt;BR /&gt;3. do proc univariate on each of each of the three groups to find the number of patients who have done each lab test, and the mean and standard deviation of each lab test for each group. So, I need to get finally:&lt;/P&gt;&lt;P&gt;The number of people who have done lab1 in groups A, B, and C (pre and post). Supposably they are equal.&lt;BR /&gt;The mean value of lab1 and lab2 values (pre and post) in the three groups.&lt;BR /&gt;The standard deviation of lab1 and lab2 values (pre and post) in the three groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that possible using a single macro?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 13:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823836#M35091</guid>
      <dc:creator>ugly_duck_ling</dc:creator>
      <dc:date>2022-07-18T13:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823837#M35092</link>
      <description>&lt;P&gt;You can do all of this without a macro at all. Why do you feel a macro is needed?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 13:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823837#M35092</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-18T13:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823838#M35093</link>
      <description>For efficiency in calculating those if needed.</description>
      <pubDate>Mon, 18 Jul 2022 13:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823838#M35093</guid>
      <dc:creator>ugly_duck_ling</dc:creator>
      <dc:date>2022-07-18T13:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823840#M35094</link>
      <description>&lt;P&gt;Macros are just a way of writing dynamic code. The efficiency of doing calculations is not improved by a macro, the code (for example, PROC UNIVARIATE) executes at the same speed regardless of whether or not a macro is used.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;What does "&lt;SPAN&gt;remove missing values" mean to you? Does it mean remove those observations entirely, or just do not use the missings, or something else?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 13:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823840#M35094</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-18T13:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823841#M35095</link>
      <description>remove the observations entirely.</description>
      <pubDate>Mon, 18 Jul 2022 13:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823841#M35095</guid>
      <dc:creator>ugly_duck_ling</dc:creator>
      <dc:date>2022-07-18T13:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can we do more than one function in a single SAS macro?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823851#M35096</link>
      <description>&lt;P&gt;Here is code to do this using PROC SUMMARY instead of PROC UNIVARIATE. The output data set which I call _STATS_ contains what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value lab1f low-&amp;lt;6='PreLab1 &amp;lt; 6' 6-high='PreLab1 &amp;gt;= 6';
    value lab2f low-&amp;lt;130='PreLab2 &amp;lt; 130' 130-high = 'PreLab2 &amp;gt;= 130';
run;
data want;
    set labs;
    changelab1=postlab1-prelab1;
    changelab2=postlab2-prelab2;
    if changelab1=. then call missing(prelab1,postlab1);
    if changelab2=. then call missing(prelab2,postlab2);
    format prelab1 lab1f. prelab2 lab2f.;
run;
proc summary data=want;
    class prelab1 prelab2;
    ways 1 2;
    var prelab1 prelab2 postlab1 postlab2 changelab1 changelab2;
    output out=_stats_ n= mean= stddev=/autoname noinherit;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2022 14:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Can-we-do-more-than-one-function-in-a-single-SAS-macro/m-p/823851#M35096</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-18T14:25:45Z</dc:date>
    </item>
  </channel>
</rss>

