<?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 Print all Variable names and Values for one record in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46076#M12211</link>
    <description>Is there a way to print all of the variables names with the value for one individual record?&lt;BR /&gt;
&lt;BR /&gt;
For example, I would like to see the following output in two columns:&lt;BR /&gt;
&lt;BR /&gt;
varname  response&lt;BR /&gt;
&lt;BR /&gt;
ID  2&lt;BR /&gt;
FNAME  JOHN&lt;BR /&gt;
LNAME  DOE&lt;BR /&gt;
DOB  10/10/1910&lt;BR /&gt;
PHONE  555-555-5555&lt;BR /&gt;
ZIP  56879&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help!</description>
    <pubDate>Tue, 07 Dec 2010 16:27:01 GMT</pubDate>
    <dc:creator>statadm</dc:creator>
    <dc:date>2010-12-07T16:27:01Z</dc:date>
    <item>
      <title>Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46076#M12211</link>
      <description>Is there a way to print all of the variables names with the value for one individual record?&lt;BR /&gt;
&lt;BR /&gt;
For example, I would like to see the following output in two columns:&lt;BR /&gt;
&lt;BR /&gt;
varname  response&lt;BR /&gt;
&lt;BR /&gt;
ID  2&lt;BR /&gt;
FNAME  JOHN&lt;BR /&gt;
LNAME  DOE&lt;BR /&gt;
DOB  10/10/1910&lt;BR /&gt;
PHONE  555-555-5555&lt;BR /&gt;
ZIP  56879&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance for your help!</description>
      <pubDate>Tue, 07 Dec 2010 16:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46076#M12211</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-12-07T16:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46077#M12212</link>
      <description>Hi:&lt;BR /&gt;
  Will you only do this for 1 observation or do you want this format for EVERY observation in a group? What is your destination of interest? (RTF, PDF, HTML)? Are DOB, PHONE and ZIP character or numeric variables?  SAS expects an entire column of values to be of the same type (so, for example, if you had a column for SALES, then the value for SALES for EVERY row would be numeric). &lt;BR /&gt;
 &lt;BR /&gt;
  In your example, FNAME, LNAME and possibly PHONE might be character, but DOB and ZIP might be numeric -- SAS would "want" the second column to be all character -- which would mean that you would have to convert DOB and ZIP to character variables in order to display them in the same column with FNAME, LNAME and PHONE.&lt;BR /&gt;
 &lt;BR /&gt;
Otherwise, the example is sort of like an example in a previous forum posting:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=46738뚒" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=46738뚒&lt;/A&gt; (except in that post, all the variables were character.)&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 07 Dec 2010 17:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46077#M12212</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-07T17:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46078#M12213</link>
      <description>So, I only need to do this for one observation.  What I really want to do is take a dataset that is in wide format and transpose it to long.  &lt;BR /&gt;
&lt;BR /&gt;
All of the variables are different format types (there are over 3000 variables).&lt;BR /&gt;
&lt;BR /&gt;
It doesn't matter which destination, anything will work.&lt;BR /&gt;
&lt;BR /&gt;
If it isn't possible, I guess I can just proc print everything for that one observation.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Tue, 07 Dec 2010 17:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46078#M12213</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-12-07T17:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46079#M12214</link>
      <description>Could you just use PROC TRANSPOSE with a WHERE statement to identify the one observation?  Here is an example.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA HAVE;&lt;BR /&gt;
	INPUT ID $ FNAME:$12. LNAME:$12. DOB:MMDDYY10. PHONE:$12. ZIP $;&lt;BR /&gt;
	FORMAT DOB MMDDYY10.;&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
1 JANE DOE 01/01/2001 999-999-9999 12345&lt;BR /&gt;
2 JOHN DOE 10/10/1910 555-555-5555 56789&lt;BR /&gt;
3 JIM  DOE 12/12/1912 111-111-1111 34567&lt;BR /&gt;
;;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC TRANSPOSE DATA=HAVE OUT=WANT(RENAME=(COL1=VALUE)) NAME=VARIABLE;&lt;BR /&gt;
	VAR _ALL_;&lt;BR /&gt;
	WHERE ID = '2';&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC PRINT DATA=WANT NOOBS;&lt;BR /&gt;
RUN;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 07 Dec 2010 17:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46079#M12214</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2010-12-07T17:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46080#M12215</link>
      <description>Hi:&lt;BR /&gt;
  Did you look at this program:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=46738뚒" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=46738뚒&lt;/A&gt; &lt;BR /&gt;
 &lt;BR /&gt;
  It essentially transposes 4 character variables in a DATA step program and then uses PROC REPORT to create the kind of output you want. The only differences in what you would have to do is:&lt;BR /&gt;
1) you'd subset your data so you'd only have 1 obs of interest and&lt;BR /&gt;
2) you'd have to use a DATA step and  the PUT function to convert all your numeric variables to character and this means that&lt;BR /&gt;
3) if you had special user-defined formats, you'd have to take those into account&lt;BR /&gt;
 &lt;BR /&gt;
OR &lt;BR /&gt;
you'd have to run PROC TRANSPOSE -- this will be easier if you do only have ONE observation. See the example below.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
** alternate approach;&lt;BR /&gt;
proc sort data=sashelp.class &lt;BR /&gt;
          out=onlyone;&lt;BR /&gt;
   where name in ('Alfred');&lt;BR /&gt;
   by name;&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
** transpose all variables -- usually only numeric are transposed;&lt;BR /&gt;
** there will be a note in the log about automatic conversion of;&lt;BR /&gt;
** numeric to character -- if you do not want this automatic conversion,&lt;BR /&gt;
** (for example, if you have user-defined formats);&lt;BR /&gt;
proc transpose data=onlyone out=charout;&lt;BR /&gt;
var _character_ _numeric_;&lt;BR /&gt;
run;&lt;BR /&gt;
             &lt;BR /&gt;
proc print data=charout;&lt;BR /&gt;
run;&lt;BR /&gt;
                     &lt;BR /&gt;
proc report data=charout nowd;&lt;BR /&gt;
  column _NAME_ COL1;&lt;BR /&gt;
  define _NAME_ / display 'ID';&lt;BR /&gt;
  define COL1 / display 'Value';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 07 Dec 2010 18:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46080#M12215</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-12-07T18:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Print all Variable names and Values for one record</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46081#M12216</link>
      <description>Yes, thank you!</description>
      <pubDate>Tue, 07 Dec 2010 22:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Print-all-Variable-names-and-Values-for-one-record/m-p/46081#M12216</guid>
      <dc:creator>statadm</dc:creator>
      <dc:date>2010-12-07T22:20:27Z</dc:date>
    </item>
  </channel>
</rss>

