<?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 PROC REPORT compute block: How to map a variable value to the line text without hardcoding? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956264#M26798</link>
    <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I remember being able to map variable value into LINE statement text in the past, but cannot figure out it now. I believe there is an elementary item that I'm missing (which is unfamiliar to me).&amp;nbsp;&lt;BR /&gt;Currently,&amp;nbsp; to map a variable value into the LINE I keep hardcoding, eg. using IF/ELSE (see below #1).&amp;nbsp; Could anyone fix #2 and explain how to avoid hardcoding part?&amp;nbsp;&lt;BR /&gt;Many thanks!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input visitnum visit $;
	if visit eq 'Screen' then do score= 1 to 5; output; end; 
	else do score= 1 to 6; output; end; 
	cards;
 1 Screen
 2 Week_1
 3 Week_2
 4 Week_3
;
run; 

proc format;
	value score 1= 'Very severe'
				2= 'Severe'
				3= 'Moderate'
				4= 'Mild'
				5= 'Minimal'
				6= 'No pain';
run; 


/*	1. Current coding */
proc report data=have;
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/ noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	compute before visitnum/style={just=l}; 
		line @1 text $40.;
		length text $40;
		if visitnum=1 then text='Screen';
		else if visitnum=2 then text='Week_1';
		else if visitnum=3 then text='Week_2';
		else if visitnum=4 then text='Week_3';
	endcomp; 
run; 

/*	2. Wanted coding - needs to be fixed to get the same result as #1*/
proc report data=have;
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/ noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	compute before visitnum/style={just=l}; 
		line @1 text $40.;
		length text $40;
		text=visit;
	endcomp; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jan 2025 00:32:23 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2025-01-16T00:32:23Z</dc:date>
    <item>
      <title>PROC REPORT compute block: How to map a variable value to the line text without hardcoding?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956264#M26798</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I remember being able to map variable value into LINE statement text in the past, but cannot figure out it now. I believe there is an elementary item that I'm missing (which is unfamiliar to me).&amp;nbsp;&lt;BR /&gt;Currently,&amp;nbsp; to map a variable value into the LINE I keep hardcoding, eg. using IF/ELSE (see below #1).&amp;nbsp; Could anyone fix #2 and explain how to avoid hardcoding part?&amp;nbsp;&lt;BR /&gt;Many thanks!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input visitnum visit $;
	if visit eq 'Screen' then do score= 1 to 5; output; end; 
	else do score= 1 to 6; output; end; 
	cards;
 1 Screen
 2 Week_1
 3 Week_2
 4 Week_3
;
run; 

proc format;
	value score 1= 'Very severe'
				2= 'Severe'
				3= 'Moderate'
				4= 'Mild'
				5= 'Minimal'
				6= 'No pain';
run; 


/*	1. Current coding */
proc report data=have;
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/ noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	compute before visitnum/style={just=l}; 
		line @1 text $40.;
		length text $40;
		if visitnum=1 then text='Screen';
		else if visitnum=2 then text='Week_1';
		else if visitnum=3 then text='Week_2';
		else if visitnum=4 then text='Week_3';
	endcomp; 
run; 

/*	2. Wanted coding - needs to be fixed to get the same result as #1*/
proc report data=have;
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/ noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	compute before visitnum/style={just=l}; 
		line @1 text $40.;
		length text $40;
		text=visit;
	endcomp; 
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 00:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956264#M26798</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-01-16T00:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT compute block: How to map a variable value to the line text without hardcoding?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956270#M26799</link>
      <description>&lt;P&gt;Hi, It seems to me, based on your test data that VISITNUM and VISIT are tied together and change at the same time. So if you just change which variable you're using for the COMPUTE BEFORE and make VISIT an ORDER item too, it will greatly simplify your code. I changed the style for the LINE in the COMPUTE block to HEADER, so it was more prominent.&lt;/P&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1736991814587.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103739i5C0EF93DAEAA00BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1736991814587.png" alt="Cynthia_sas_0-1736991814587.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternate code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*	ALTERNATE coding */
proc report data=have;
  title 'ALTERNATE coding';
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/ order noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	compute before visit/style=Header{just=l}; 
		line @1 visit $40.;
 	endcomp; 
run; 
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 01:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956270#M26799</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2025-01-16T01:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT compute block: How to map a variable value to the line text without hardcoding?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956276#M26800</link>
      <description>&lt;PRE&gt;data have;
	input visitnum visit $;
	if visit eq 'Screen' then do score= 1 to 5; output; end; 
	else do score= 1 to 6; output; end; 
	cards;
 1 Screen
 2 Week_1
 3 Week_2
 4 Week_3
;
run; 

proc format;
	value score 1= 'Very severe'
				2= 'Severe'
				3= 'Moderate'
				4= 'Mild'
				5= 'Minimal'
				6= 'No pain';

run; 


/*	1. Current coding */
proc report data=have nowd;
	column visitnum visit score;
	define visitnum/order noprint;
	define visit/&lt;STRONG&gt;order&lt;/STRONG&gt; noprint;
	define score/'Response Category' format=score. style(column)={just=l} display;
	&lt;STRONG&gt;compute before visit/style={just=l}; 
		line @1 visit $40.;
	endcomp;&lt;/STRONG&gt; 
run; 
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1736992706103.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103740iEA3472426FABF507/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1736992706103.png" alt="Ksharp_0-1736992706103.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 01:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956276#M26800</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-16T01:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT compute block: How to map a variable value to the line text without hardcoding?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956460#M26801</link>
      <description>&lt;P&gt;Thank you, Cynthia!&lt;BR /&gt;"Header" element is very helpful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 20:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956460#M26801</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-01-17T20:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT compute block: How to map a variable value to the line text without hardcoding?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956461#M26802</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;!&lt;BR /&gt;Appreciate your input!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 20:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-REPORT-compute-block-How-to-map-a-variable-value-to-the/m-p/956461#M26802</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-01-17T20:33:32Z</dc:date>
    </item>
  </channel>
</rss>

