<?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: Bring three columns into one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71349#M15440</link>
    <description>Hi:&lt;BR /&gt;
  To me, it almost sounds like you want a line feed or carriage return in your display??? I would interpret this as being that you are moving into the world of REPORTS and procedure output (such as PROC PRINT/PROC REPORT), because SAS datasets do NOT have line feeds and carriage returns.&lt;BR /&gt;
&lt;BR /&gt;
  What would be your procedure of choice to create this report??? And what would be your ODS destination of choice?? HTML, RTF or PDF???&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
    <pubDate>Fri, 26 Mar 2010 20:59:14 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2010-03-26T20:59:14Z</dc:date>
    <item>
      <title>Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71342#M15433</link>
      <description>Hi all,&lt;BR /&gt;
 My SAS dataset has three columns ID,age,gender.How to I bring all three values into a single column one below the other.&lt;BR /&gt;
For instance:&lt;BR /&gt;
&lt;BR /&gt;
From:&lt;BR /&gt;
&lt;BR /&gt;
ID      age    gender&lt;BR /&gt;
11       25      Male&lt;BR /&gt;
&lt;BR /&gt;
to  :&lt;BR /&gt;
&lt;BR /&gt;
New_column&lt;BR /&gt;
11&lt;BR /&gt;
25&lt;BR /&gt;
Male</description>
      <pubDate>Fri, 26 Mar 2010 03:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71342#M15433</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-03-26T03:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71343#M15434</link>
      <description>data have;&lt;BR /&gt;
	input ID age gender $;&lt;BR /&gt;
cards;&lt;BR /&gt;
11 25 Male&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=have out=want(drop=_name_ rename=(col1=New_column));&lt;BR /&gt;
	var id age gender;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want(drop=i);&lt;BR /&gt;
	set want;&lt;BR /&gt;
	array tmp&lt;LI&gt; _all_;&lt;BR /&gt;
	do i=1 to dim(tmp);&lt;BR /&gt;
		tmp&lt;I&gt;=strip(tmp&lt;I&gt;);&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;/I&gt;&lt;/I&gt;&lt;/LI&gt;</description>
      <pubDate>Fri, 26 Mar 2010 05:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71343#M15434</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-26T05:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71344#M15435</link>
      <description>data have;&lt;BR /&gt;
	input ID age gender $;&lt;BR /&gt;
cards;&lt;BR /&gt;
11 25 Male&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data want(keep=New_column);&lt;BR /&gt;
	set have;&lt;BR /&gt;
	array num&lt;LI&gt; _numeric_;&lt;BR /&gt;
	array char&lt;/LI&gt;&lt;LI&gt; _character_;&lt;BR /&gt;
	length New_column $ 10;&lt;BR /&gt;
	do i=1 to dim(num);&lt;BR /&gt;
		New_column=strip(put(num&lt;I&gt;,best.));&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	do j=1 to dim(char);&lt;BR /&gt;
		New_column=strip(char&lt;J&gt;);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;/J&gt;&lt;/I&gt;&lt;/LI&gt;</description>
      <pubDate>Fri, 26 Mar 2010 05:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71344#M15435</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-26T05:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71345#M15436</link>
      <description>To generate the output display shown be the OP, it requires a DATA step  most likely - use a SAS PUT statement to generate the "vertical" variable value display.  It is not necessary to create a new column, if you only want to display the information vertically instead of horizontally.&lt;BR /&gt;
&lt;BR /&gt;
PUT 'header_info' / var1 / var2 / var3 ;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 26 Mar 2010 11:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71345#M15436</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-26T11:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71346#M15437</link>
      <description>Here is a variation on your program that you may find interesting.  Can you see the modest advantage over using ARRAYS?  I can think of 2 advantages.&lt;BR /&gt;
&lt;BR /&gt;
We still have to insure the receiving variable has the proper length.  PROC TRANSPOSE will handle that for us which is an advantage with PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   input ID $ age gender $;&lt;BR /&gt;
   cards;&lt;BR /&gt;
11 25 Male&lt;BR /&gt;
12 24 FeMale&lt;BR /&gt;
13 25 Male&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
data tall(keep=Column);&lt;BR /&gt;
   set have;&lt;BR /&gt;
   length _name_ $32 Column $12;&lt;BR /&gt;
   do while(1);&lt;BR /&gt;
      call vnext(_name_);&lt;BR /&gt;
      if _name_ eq '_name_' then leave;&lt;BR /&gt;
      column = left(vvalueX(_name_));&lt;BR /&gt;
      output;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 26 Mar 2010 13:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71346#M15437</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-03-26T13:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71347#M15438</link>
      <description>data _null_ -- Swwwweet!&lt;BR /&gt;
&lt;BR /&gt;
Scott</description>
      <pubDate>Fri, 26 Mar 2010 13:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71347#M15438</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-03-26T13:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71348#M15439</link>
      <description>Hi data _null_,&lt;BR /&gt;
 instead of getting the columns as different obeservations, the user needs them as single record for each row of data.&lt;BR /&gt;
for instance:&lt;BR /&gt;
data have;   &lt;BR /&gt;
input ID $ age gender $;   &lt;BR /&gt;
cards;&lt;BR /&gt;
11 25 Male&lt;BR /&gt;
12 24 FeMale&lt;BR /&gt;
13 25 Male;;;;   &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The output should look like(3 records, instead of 9):&lt;BR /&gt;
11&lt;BR /&gt;
12&lt;BR /&gt;
male&lt;BR /&gt;
&lt;BR /&gt;
12&lt;BR /&gt;
24&lt;BR /&gt;
female&lt;BR /&gt;
&lt;BR /&gt;
13&lt;BR /&gt;
25&lt;BR /&gt;
male&lt;BR /&gt;
&lt;BR /&gt;
the above display is actually three rows only.NOT 9&lt;BR /&gt;
&lt;BR /&gt;
thanks</description>
      <pubDate>Fri, 26 Mar 2010 20:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71348#M15439</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-03-26T20:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71349#M15440</link>
      <description>Hi:&lt;BR /&gt;
  To me, it almost sounds like you want a line feed or carriage return in your display??? I would interpret this as being that you are moving into the world of REPORTS and procedure output (such as PROC PRINT/PROC REPORT), because SAS datasets do NOT have line feeds and carriage returns.&lt;BR /&gt;
&lt;BR /&gt;
  What would be your procedure of choice to create this report??? And what would be your ODS destination of choice?? HTML, RTF or PDF???&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 26 Mar 2010 20:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71349#M15440</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-26T20:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71350#M15441</link>
      <description>Cynthia,&lt;BR /&gt;
The choices are proc report and rtf.</description>
      <pubDate>Sat, 27 Mar 2010 01:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71350#M15441</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-03-27T01:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71351#M15442</link>
      <description>I don't get it.</description>
      <pubDate>Sat, 27 Mar 2010 01:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71351#M15442</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-03-27T01:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71352#M15443</link>
      <description>Hi:&lt;BR /&gt;
  Consider using ODS ESCAPECHAR, as described in these papers (some of them show 9.1.3 version of ESCAPECHAR syntax and some of them show the 9.2 ESCAPECHAR syntax):&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2007/099-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/099-2007.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/227-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/227-31.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/forum2007/144-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/144-2007.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.nesug.org/Proceedings/nesug07/cc/cc18.pdf" target="_blank"&gt;http://www.nesug.org/Proceedings/nesug07/cc/cc18.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://www.abtassoc.org/presentations/lsh3_2009.pdf" target="_blank"&gt;https://www.abtassoc.org/presentations/lsh3_2009.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.nesug.org/proceedings/nesug08/np/np10.pdf" target="_blank"&gt;http://www.nesug.org/proceedings/nesug08/np/np10.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Or RTF control strings (such as \line) as shown in the example below.&lt;BR /&gt;
&lt;BR /&gt;
to insert a LINE FEED or "return" into  a character variable. In the first example below, I use a DATA step program to create a variable called STKVAR -- which contains the concatenated NAME, SEX, AGE and HEIGHT variable information from SASHELP.CLASS&lt;BR /&gt;
&lt;BR /&gt;
Note that there are 4 "lines" in every row of the report. Example 1 uses a DATA step to build STKVAR and RTFCTL; Example 2 uses PROC REPORT and a COMPUTE block and NOPRINT variables to build VAR1 and VAR2; and both examples also show the use of RTF controls strings instead of using ODS ESCAPECHAR methods.&lt;BR /&gt;
            &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
data class;&lt;BR /&gt;
  length stkvar $75 rtfctl $75;&lt;BR /&gt;
  set sashelp.class(obs=3);&lt;BR /&gt;
  stkvar = catx('~n',name,sex,put(age,2.0),put(height,5.1));&lt;BR /&gt;
  rtfctl = catt(name,'\line{',sex,'}\line{',put(age,2.0),'}\line{',put(height,5.1),'}');&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
options nodate nonumber;&lt;BR /&gt;
ods listing close;&lt;BR /&gt;
ods rtf file='make_stacked_report_col1.rtf';&lt;BR /&gt;
ods escapechar='~';&lt;BR /&gt;
               &lt;BR /&gt;
** listing individual vars here to show line feeds inserted correctly;&lt;BR /&gt;
** cellwidth set to show effect of just=c;&lt;BR /&gt;
proc report data=class nowd split='*';&lt;BR /&gt;
  title '1)Using ODS ESCAPECHAR To Put a Line Feed into a REPORT Column';&lt;BR /&gt;
  title2 'Also using RTF control strings to put a "\line" command into a cell';&lt;BR /&gt;
  column name sex age height stkvar rtfctl;&lt;BR /&gt;
  define stkvar / "Use ESCAPECHAR*Method" &lt;BR /&gt;
         style(column)={just=c cellwidth=1.5in};&lt;BR /&gt;
  define rtfctl / "Use RTF*Control String"&lt;BR /&gt;
         style(column)={just=c protectspecialchars=off cellwidth=1.5in};&lt;BR /&gt;
run;&lt;BR /&gt;
                    &lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
            &lt;BR /&gt;
ods rtf file='make_stacked_report_col2.rtf';&lt;BR /&gt;
ods escapechar='~';&lt;BR /&gt;
            &lt;BR /&gt;
** Using NOPRINT here to hide cols used to build col with line feed;&lt;BR /&gt;
** kept cellwidth to show just=c;&lt;BR /&gt;
proc report data=sashelp.class(obs=3) nowd split='*';&lt;BR /&gt;
  title '2)Making all the report columns in PROC REPORT';&lt;BR /&gt;
  title2 'All the variables used to build the new report item are NOPRINT';&lt;BR /&gt;
  title3 'But they do not need to be NOPRINT items';&lt;BR /&gt;
  column name sex age height var1 var2;&lt;BR /&gt;
  define name / order noprint;&lt;BR /&gt;
  define sex / display noprint;&lt;BR /&gt;
  define age / display noprint;&lt;BR /&gt;
  define height / display noprint;&lt;BR /&gt;
  define var1 / computed "Use ESCAPECHAR*Method" &lt;BR /&gt;
         style(column)={just=c cellwidth=1.5in};&lt;BR /&gt;
  define var2 / computed "Use RTF*Control String"&lt;BR /&gt;
         style(column)={just=c protectspecialchars=off cellwidth=1.5in};&lt;BR /&gt;
  compute var1 / character length=75;&lt;BR /&gt;
     var1 = catx('~n',name,sex,put(age,2.0),put(height,5.1));&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  compute var2 / character length=75;&lt;BR /&gt;
     var2 = catt(name,'\line{',sex,'}\line{',put(age,2.0),'}\line{',put(height,5.1),'}');&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
run;&lt;BR /&gt;
                           &lt;BR /&gt;
ods rtf close;&lt;BR /&gt;
&lt;BR /&gt;
              &lt;BR /&gt;
[/pre]</description>
      <pubDate>Sat, 27 Mar 2010 01:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71352#M15443</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-03-27T01:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Bring three columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71353#M15444</link>
      <description>I think we're not getting enough of the story.&lt;BR /&gt;
&lt;BR /&gt;
But, to keep things simple.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  file "output";&lt;BR /&gt;
  set indata;&lt;BR /&gt;
  put "Column name" / ID $ / age / gender $ ;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 31 Mar 2010 14:29:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bring-three-columns-into-one/m-p/71353#M15444</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-31T14:29:18Z</dc:date>
    </item>
  </channel>
</rss>

