<?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: call symput in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799522#M314395</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;The put function converts a numeric variable to a character variable, and the input function converts a character variable to a numeric variable&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The second part of this is not (completely) true; while the INPUT function is typically used for this type of conversion, it can yield a character result also:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue $insex (default=1)
  "male" = "M"
  "female" = "F"
;
run;

data want;
input instring $6.;
sex = input(instring,$insex.);
datalines;
male
female
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the resulting dataset, sex will be a character variable of length 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2022 08:29:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-02T08:29:10Z</dc:date>
    <item>
      <title>call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799514#M314390</link>
      <description>&lt;P&gt;Hi can you explain to me what call symput does, I read the manual and cannot understand..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also could you also explain put and input with a simple example, I also struggle with what is said in the manual&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks a lot...&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 07:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799514#M314390</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-02T07:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799516#M314392</link>
      <description>&lt;P&gt;call symput can store the value of a variable into a macro variable in the data step&lt;BR /&gt;In the following, the value of Alfred's SEX is stored in the macro variable "MACRO_SEX".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample0;
  set sashelp.class;
  if(name='Alfred')then do;
    call symput('MACRO_SEX',SEX);
  end;
run;

%put &amp;amp;=MACRO_SEX;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that there are statements and functions for put and input.&lt;BR /&gt;The put function converts a numeric variable to a character variable, and the input function converts a character variable to a numeric variable&lt;BR /&gt;The put statement outputs the value of a variable to a log or file, and the input statement imports the value specified in a file or datalines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Convert age to character with put function&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample2;
  set sample1;
  AGE_N=input(AGE_C,3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Converting characters to numbers with the input function&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample1;
  set sashelp.class;
  AGE_C=put(age,3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output name and age to the log with put statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample3;
  set sashelp.class;
  put name age;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Converting Values Described in Datalines into Data Sets with the input Statement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input name $ age;
datalines;
ALFRED 14
ALICE 13
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 07:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799516#M314392</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-03-02T07:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799522#M314395</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;The put function converts a numeric variable to a character variable, and the input function converts a character variable to a numeric variable&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The second part of this is not (completely) true; while the INPUT function is typically used for this type of conversion, it can yield a character result also:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
invalue $insex (default=1)
  "male" = "M"
  "female" = "F"
;
run;

data want;
input instring $6.;
sex = input(instring,$insex.);
datalines;
male
female
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the resulting dataset, sex will be a character variable of length 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 08:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799522#M314395</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-02T08:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799523#M314396</link>
      <description>&lt;P&gt;Which part of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p09y28i2d1kn8qn1p1icxchz37p3.htm" target="_blank" rel="noopener"&gt;CALL SYMPUT documentation&lt;/A&gt; puzzles you?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 08:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799523#M314396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-02T08:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799541#M314406</link>
      <description>&lt;P&gt;I was not sure if it has to be a macro variable that the value of the variable is assigned to as looking at it, it does not like relating to macro variables...&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 10:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799541#M314406</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-02T10:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799543#M314408</link>
      <description>&lt;P&gt;The first sentence makes that very clear:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Assigns a value produced in a DATA step to a &lt;FONT color="#FF0000"&gt;macro variable&lt;/FONT&gt;.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 10:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799543#M314408</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-02T10:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: call symput</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799574#M314425</link>
      <description>&lt;P&gt;It helps to know that SAS will also use the term SYMBOL for macro variables.&amp;nbsp; &amp;nbsp; Hence the SYM in CALL SYMPUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should also know that you should limit the use of CALL SYMPUT() to situations where you need to store leading and/or trailing spaces into the symbol or macro variable.&amp;nbsp; 99% of the time you want to use the newer and more powerful CALL SYMPUTX() function instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To understand PUT, PUT(), PUTN(), PUTC(),&amp;nbsp; INPUT, INPUT(), INPUTN() and INPUTC() you need to understand FORMATs and INFORMATs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format is instructions for how to convert values into TEXT.&amp;nbsp; An informat is instructions for how to convert TEXT into values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use the INPUT statement to read from text into values.&amp;nbsp; If you use a numeric informat then the resulting value is a number.&amp;nbsp; If you use a character informat then the value is a character string.&amp;nbsp; The INPUT() function allows you to use the informat it situations where the source of the text is a variable or other SAS expression and the target is a variable (or part of larger SAS expression).&amp;nbsp; What type of value the INPUT() produces depends on the type of informat used.&amp;nbsp; With the INPUTN() or INPUTC() the type of value is explicit in the name of the function.&amp;nbsp; With INPUTN() and INPUTC() the informat specification to use is taken from a character expression.&amp;nbsp; So you can generate what informat to use dynamically.&amp;nbsp; Or you could use a constant value, but instead of code syntax you have to pass it as a string literal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use the PUT statement to write value as text to a file (which includes the SAS log file or output window).&amp;nbsp; If the value you are writing is a number you need to use a numeric format.&amp;nbsp; If the value is character you need to use a character format.&amp;nbsp; The&amp;nbsp; PUT() function allows you to the format in situations where the source of the vlaue is a variable or other expression and the target is a variable (or part of larger SAS expression).&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 14:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-symput/m-p/799574#M314425</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-02T14:38:58Z</dc:date>
    </item>
  </channel>
</rss>

