<?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: How to use/execute “Read command of unix in sas macro” in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451431#M113822</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I am using the SAS procedure within the SAS macro but read command is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;x=$(pwd)&lt;/P&gt;&lt;P&gt;{ echo "option symbolgen mprint mlogic ;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;echo "libname sasdata '$x' access=readonly ;"&lt;/P&gt;&lt;P&gt;echo "%macro read;"&lt;BR /&gt;echo 'x "echo -n 'Enter Name:';&lt;BR /&gt;read name;&lt;BR /&gt;echo Datset name is [$name];" '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;echo 'x cd $x;'&lt;/P&gt;&lt;P&gt;echo "libname sasdata '$x' access=readonly ;"&lt;BR /&gt;echo "proc freq data=sasdata.$name ;"&lt;BR /&gt;echo "tables _character_ / missing;"&lt;BR /&gt;echo "run;"&lt;BR /&gt;echo '%mend;'&lt;/P&gt;&lt;P&gt;echo '%read;'&lt;BR /&gt;} &amp;gt; $x/read.sas&lt;BR /&gt;cd $x&lt;BR /&gt;sas "$x/read.sas"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But here again $name is getting resolved.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 10:07:49 GMT</pubDate>
    <dc:creator>manoj_pandey</dc:creator>
    <dc:date>2018-04-05T10:07:49Z</dc:date>
    <item>
      <title>How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451408#M113818</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;Below is the script, In which I am trying to execute the "read sub" but unfortunately not able to get the expected result and giving the null&amp;nbsp; value for "$sub".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Example: Below is the prompt massage which I am getting but the expected result should&amp;nbsp;be&amp;nbsp; in 2) example.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Sub setting condition:check&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;Checking the macro []&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;2)&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Sub setting condition:check&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;Checking the macro [check]&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;#!/bin/sh

{
echo '%macro read;'

echo '%sysexec ( echo -n "Sub setting condition:");'
echo '%sysexec ( read sub) ;'
echo '%sysexec ( echo "Checking the macro [$sub]");'

echo '%mend;'

echo '%read;'
} &amp;gt; "/home/read.sas"
cd /home
sas /home/read.sas&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 06:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451408#M113818</guid>
      <dc:creator>manoj_pandey</dc:creator>
      <dc:date>2018-04-05T06:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451412#M113819</link>
      <description>&lt;P&gt;%sysexec spawns a process. read reads into a variable in the environment of that process. Once that process terminates (upon the return from the %sysexec), these changes are lost, and in the next spawned process from the next %sysexec the environment variable sub does not exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Making SAS batch programs interactive is counter-intuitive at best.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 06:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451412#M113819</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T06:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451427#M113820</link>
      <description>&lt;P&gt;If you want to feed user input from the commandline into a SAS program, do the read in the outermost shell script, and then retrieve the value in the SAS program with %sysget.&lt;/P&gt;
&lt;P&gt;shell script example:&lt;/P&gt;
&lt;PRE&gt;#!/usr/bin/bash
# this script is written for AIX

echo -n condition: 
read SUB
export SUB
sas $HOME/sascommunity/test.sas
&lt;/PRE&gt;
&lt;P&gt;SAS program test.sas:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let inputval=%sysget(SUB);

x "/usr/bin/echo &amp;amp;inputval";
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 09:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451427#M113820</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T09:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451430#M113821</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;Hi Kurt,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank you for suggestion.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Below script is working for my problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;#!/bin/sh

{
echo '%macro read;'
&lt;BR /&gt;echo 'x "echo -n 'Sub setting condition:'; &lt;BR /&gt;         read sub; &lt;BR /&gt;          echo Checking the macro [$sub];" ' &lt;BR /&gt;echo '%mend;'

echo '%read;'
} &amp;gt; "/home/read.sas"
cd /home
sas /home/read.sas&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have kept all the command in only one X command so that echo and read command will work in a single execution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 09:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451430#M113821</guid>
      <dc:creator>manoj_pandey</dc:creator>
      <dc:date>2018-04-05T09:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451431#M113822</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I am using the SAS procedure within the SAS macro but read command is not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;x=$(pwd)&lt;/P&gt;&lt;P&gt;{ echo "option symbolgen mprint mlogic ;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;echo "libname sasdata '$x' access=readonly ;"&lt;/P&gt;&lt;P&gt;echo "%macro read;"&lt;BR /&gt;echo 'x "echo -n 'Enter Name:';&lt;BR /&gt;read name;&lt;BR /&gt;echo Datset name is [$name];" '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;echo 'x cd $x;'&lt;/P&gt;&lt;P&gt;echo "libname sasdata '$x' access=readonly ;"&lt;BR /&gt;echo "proc freq data=sasdata.$name ;"&lt;BR /&gt;echo "tables _character_ / missing;"&lt;BR /&gt;echo "run;"&lt;BR /&gt;echo '%mend;'&lt;/P&gt;&lt;P&gt;echo '%read;'&lt;BR /&gt;} &amp;gt; $x/read.sas&lt;BR /&gt;cd $x&lt;BR /&gt;sas "$x/read.sas"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But here again $name is getting resolved.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451431#M113822</guid>
      <dc:creator>manoj_pandey</dc:creator>
      <dc:date>2018-04-05T10:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use/execute “Read command of unix in sas macro”</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451438#M113823</link>
      <description>&lt;PRE&gt;read name;&lt;/PRE&gt;
&lt;P&gt;is not part of the SAS program, but part of the shell script. And the shell script resolves $name for you and writes it into the SAS program:&lt;/P&gt;
&lt;PRE&gt;echo "proc freq data=sasdata.$name ;"&lt;/PRE&gt;
&lt;P&gt;What I do differently is that I do not write the program from the shell script, but instead have a static program text that is made dynamic through the use of the sysget() function.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 10:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-execute-Read-command-of-unix-in-sas-macro/m-p/451438#M113823</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-05T10:24:57Z</dc:date>
    </item>
  </channel>
</rss>

