<?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 About stringing out in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572680#M161637</link>
    <description>&lt;P&gt;Hello programmers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe i am closer to what i want to implement but i may be missing something and i need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to string out my dataset where the testcodes (tc) include not only my heart variables (heart1-heart6) but BMI as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My heart variables are coded as dichotomous (1/0) while BMI is continuous.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to modify my array and proc format by adding BMI to the end of both my array and format but i have not been successful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data me;
input id	sex	race	agecat	health	bmi	bmigroup	heart1	heart2	heart3	heart4	heart5	heart6	death	tc	Tn $	value;
datalines;
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	1	Angina	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	2	Heartburn	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	3	Sleepiness	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	4	Exercise  0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	5	Palpitation	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	6	Any  1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	1	Angina	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	2	Heartburn	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	3	Sleepiness	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	4	Exercise 1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	5	Palpitation	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	6	Any  1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	1	Angina	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	2	Heartburn	1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	3	Sleepiness	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	4	Exercise  0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	5	Palpitation	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	6	Any 	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	1	Angina	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	2	Heartburn	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	3	Sleepiness	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	4	Exercise  1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	5	Palpitation	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	6	Any  1
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	1	Angina	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	2	Heartburn	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	3	Sleepiness	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	4	Exercise  0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	5	Palpitation	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	6	Any  0
; run;
proc print; run;

/*format and stringing out*/
Proc format;
value testcodefm
1= 'Angina'
2= 'Heartburn'
3= 'Sleepiness'
4= 'Exercise'
5= 'Palpitation'
6= 'Any'
7= 'BMI'
;
data You; set me;
array him heart1-heart6 BMI;
do over him;
tc=_I_;
tn= put(tc,testcodefm.);
value=him;
output; end;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Jul 2019 12:14:32 GMT</pubDate>
    <dc:creator>ChuksManuel</dc:creator>
    <dc:date>2019-07-11T12:14:32Z</dc:date>
    <item>
      <title>About stringing out</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572680#M161637</link>
      <description>&lt;P&gt;Hello programmers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe i am closer to what i want to implement but i may be missing something and i need help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to string out my dataset where the testcodes (tc) include not only my heart variables (heart1-heart6) but BMI as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My heart variables are coded as dichotomous (1/0) while BMI is continuous.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to modify my array and proc format by adding BMI to the end of both my array and format but i have not been successful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data me;
input id	sex	race	agecat	health	bmi	bmigroup	heart1	heart2	heart3	heart4	heart5	heart6	death	tc	Tn $	value;
datalines;
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	1	Angina	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	2	Heartburn	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	3	Sleepiness	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	4	Exercise  0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	5	Palpitation	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	6	Any  1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	1	Angina	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	2	Heartburn	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	3	Sleepiness	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	4	Exercise 1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	5	Palpitation	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	6	Any  1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	1	Angina	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	2	Heartburn	1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	3	Sleepiness	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	4	Exercise  0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	5	Palpitation	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	6	Any 	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	1	Angina	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	2	Heartburn	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	3	Sleepiness	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	4	Exercise  1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	5	Palpitation	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	6	Any  1
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	1	Angina	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	2	Heartburn	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	3	Sleepiness	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	4	Exercise  0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	5	Palpitation	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	6	Any  0
; run;
proc print; run;

/*format and stringing out*/
Proc format;
value testcodefm
1= 'Angina'
2= 'Heartburn'
3= 'Sleepiness'
4= 'Exercise'
5= 'Palpitation'
6= 'Any'
7= 'BMI'
;
data You; set me;
array him heart1-heart6 BMI;
do over him;
tc=_I_;
tn= put(tc,testcodefm.);
value=him;
output; end;
proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572680#M161637</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2019-07-11T12:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: About stringing out</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572685#M161640</link>
      <description>&lt;P&gt;I don't understand this. What does your desired result look like given this data?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572685#M161640</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-11T12:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: About stringing out</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572687#M161642</link>
      <description>&lt;P&gt;If you use tabs in datalines, you need to tell SAS so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data me;
infile datalines dlm='09'x dsd;
input id sex race agecat health bmi bmigroup heart1 heart2 heart3 heart4 heart5 heart6 death tc Tn $ value;
datalines;
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	1	Angina	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	2	Heartburn	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	3	Sleepiness	0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	4	Exercise  0
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	5	Palpitation	1
1	0	0	5	4	22.494	2	0	1	0	0	1	1	1	6	Any  1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	1	Angina	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	2	Heartburn	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	3	Sleepiness	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	4	Exercise 1
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	5	Palpitation	0
2	1	0	5	2	20.1801	1	0	0	0	1	0	1	0	6	Any  1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	1	Angina	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	2	Heartburn	1
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	3	Sleepiness	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	4	Exercise  0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	5	Palpitation	0
3	1	0	4	2	26.3606	4	0	1	0	0	0	1	0	6	Any 	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	1	Angina	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	2	Heartburn	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	3	Sleepiness	1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	4	Exercise  1
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	5	Palpitation	0
4	0	0	4	3	25.373	3	0	0	1	1	0	1	0	6	Any  1
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	1	Angina	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	2	Heartburn	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	3	Sleepiness	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	4	Exercise  0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	5	Palpitation	0
6	0	0	4	1	24.8608	3	0	0	0	0	0	0	0	6	Any  0
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A little visual formatting goes a long way in making code more readable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*format and stringing out*/
Proc format;
value testcodefm
  1= 'Angina'
  2= 'Heartburn'
  3= 'Sleepiness'
  4= 'Exercise'
  5= 'Palpitation'
  6= 'Any'
  7= 'BMI'
;
run;

data You;
set me;
array him heart1-heart6 BMI;
do over him;
  tc = _I_;
  tn = put(tc,testcodefm.);
  value = him;
  output;
end;
keep 
run;

proc print data=you;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see form this (partial) result of the above, BMI is the last entry in a group:&lt;/P&gt;
&lt;PRE&gt;       Beob. id sex race agecat health   bmi   bmigroup heart1 heart2 heart3 heart4 heart5 heart6 death tc Tn        value

           1   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    1 Angina    0.0000
           2   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    2 Heartbur  1.0000
           3   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    3 Sleepine  0.0000
           4   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    4 Exercise  0.0000
           5   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    5 Palpitat  1.0000
           6   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    6 Any       1.0000
           7   1  0    0     5      4   22.4940     2       0      1      0      0      1      1     1    7 BMI      22.4940
&lt;/PRE&gt;
&lt;P&gt;If this is not the result you want, please post an example for that, based on your input data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS you did not define tn with a sufficient length, so the values are truncated.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 12:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572687#M161642</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-11T12:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: About stringing out</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572718#M161647</link>
      <description>&lt;P&gt;Thanks. Your insight was helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please how can i write an output statement to output the BMI as a testcode with a value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572718#M161647</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2019-07-11T13:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: About stringing out</title>
      <link>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572720#M161649</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236266"&gt;@ChuksManuel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks. Your insight was helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please how can i write an output statement to output the BMI as a testcode with a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But you already have that. See my previous post.&lt;/P&gt;
&lt;P&gt;If this is not what you want, then please (I repeat myself here) post the expected output.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 13:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/About-stringing-out/m-p/572720#M161649</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-11T13:14:17Z</dc:date>
    </item>
  </channel>
</rss>

