<?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 can we popularize %data2datastep further? in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484948#M3352</link>
    <description>&lt;P&gt;Here is what I mean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say we had a simple macro like this.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;** UPDATED **&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ds2post
/*----------------------------------------------------------------------------
Generate data step to post content of dataset on SAS Communities
----------------------------------------------------------------------------*/
(data     /* Name of dataset to post *REQ*  */
,target=  /* Name to use in generated data step. (default is memname of &amp;amp;DATA) */
,obs=20   /* Number of observations to generate */
,file=log /* Fileref or quoted physical name of file to hold generated code */
,format=  /* Optional format list to use when generating data lines */
);
%local _error;
%*---------------------------------------------------------------------------
Check user parameters.
----------------------------------------------------------------------------;
%let _error=0;
%if "%upcase(%qsubstr(&amp;amp;data,1,2))" = "-H" %then %let _error=1;
%else %if %length(&amp;amp;data) %then %do;
  %if not (%sysfunc(exist(%qscan(&amp;amp;data,1,())))
        or %sysfunc(exist(%qscan(&amp;amp;data,1,()),view))) %then %do;
    %let _error = 1;
    %put ERROR: "&amp;amp;data" is not a valid value for the DATA parameter.;
    %put ERROR: Unable to find the dataset. ;
  %end;
%end;
%else %do;
  %let _error = 1;
  %put ERROR: The DATA parameter is required.;
%end;
%if not %length(&amp;amp;target) %then %let target=%qscan(%qscan(&amp;amp;data,1,()),-1,.);
%if not %length(&amp;amp;obs) %then %let obs=20;
%else %let obs=%upcase(&amp;amp;obs);
%if "&amp;amp;obs" ne "MAX" %then %if %sysfunc(verify(&amp;amp;obs,0123456789)) %then %do;
  %let _error = 1;
  %put ERROR: "&amp;amp;obs" is not a valid value for the OBS parameter.;
  %put ERROR: Valid values are MAX or non-negative integer. ;
%end;
%if not %length(&amp;amp;file) %then %let file=log;

%if (&amp;amp;_error) %then %do;
*----------------------------------------------------------------------------;
* When there are parameter issues then write instructions to the log. ;
*----------------------------------------------------------------------------;
data _null_;
  put
  '%DS2POST'
//'SAS macro to copy data into a SAS Data Step in a '
  'form which you can post to on-line forums.'
//'Syntax:'
/ ' %ds2post(data=,target=,obs=,format=,file=)'
//' data   = Name of SAS dataset (or view) that you want to output.'
//' target = Name to use for generated dataset.'
  ' Default is to use name of the input.'
//' obs    = Number of observations to output. Use MAX to copy complete dataset.'
  ' Default is 20.'
//' file   = Fileref or quoted physical filename for code.'
  ' Default is the SAS log.'
//' format = Optional list of &amp;lt;var_list&amp;gt; &amp;lt;format spec&amp;gt; pairs to use when writing'
  ' data lines.' ' Setting format=_all_ will clear all formats so raw data'
  ' values are written.'
//'Note that this macro will NOT work well for really long data lines.'
 /'If your data has really long variables or a lot of variables then consider'
  ' splitting your dataset in order to post it.'
  ;
run;
%end;
%else %do;
*----------------------------------------------------------------------------;
* Get contents information and sort by VARNUM ;
*----------------------------------------------------------------------------;
proc contents noprint data=&amp;amp;data
  out=_contents_(keep=name varnum type length format: inform: memlabel label)
;
run;
proc sort data=_contents_ ;
  by varnum;
run;
*----------------------------------------------------------------------------;
* Generate top of data step ;
*----------------------------------------------------------------------------;
filename _code_ temp;
data _null_;
  length firstvar name $60 string $300 ;
  retain firstvar ;
  file _code_ column=cc ;
  set _contents_ end=eof ;
  if _n_=1 then do;
    put "data &amp;amp;target" @;
    if not missing(memlabel) then do;
      string=quote(trim(memlabel),"'");
      put '(label=' string ')' @;
    end;
    put ';';
  end;
  name=nliteral(name) ;
  if _n_=1 then firstvar=name;
  string=cats(ifc(type=2,'$',' '),length);
  put '  attrib ' name 'length=' string @;
  if formatl or not missing(format) then do;
     string=cats(format,ifn(formatl,formatl,.),'.',ifn(formatd,formatd,.));
     put 'format=' string @ ;
  end;
  if informl or not missing(informat) then do;
     string=cats(informat,ifn(informl,informl,.),'.',ifn(informd,informd,.));
     if cc+9+length(string)&amp;gt;80 then put / @4 @ ;
     put 'informat=' string @ ;
  end;
  if not missing(label) then do;
     string=quote(trim(label),"'");
     if cc+7&amp;gt;80 then put / @4 'label=' string @ ;
     else if cc+7+length(string)&amp;gt;80 then put 'label=' / @4 string @ ;
     else  put 'label=' string @;
  end;
  put ';' ;
  if eof then do;
     put "  infile datalines dsd dlm='|' truncover;" ;
     put '  input ' firstvar '-- ' name ';';
     put 'datalines4;' ;
  end;
run;
*----------------------------------------------------------------------------;
* Generate data lines ;
*----------------------------------------------------------------------------;
data _null_;
  file _code_ mod dsd dlm='|';
%if (&amp;amp;obs ne MAX) %then %do;
  if _n_ &amp;gt; &amp;amp;obs then stop;
%end;
  set &amp;amp;data ;
%if %length(&amp;amp;format) %then %do;
  format &amp;amp;format;
%end;
  put (_all_) (+0) ;
run;
data _null_;
  file _code_ mod ;
  put ';;;;';
run;
  %if "%qupcase(&amp;amp;file)" ne "_CODE_" %then %do;
*----------------------------------------------------------------------------;
* Copy generated code to target file name ;
*----------------------------------------------------------------------------;
data _null_ ;
  infile _code_;
  file &amp;amp;file ;
  input;
  put _infile_;
run;
  %end;
%end;
%mend ds2post ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So with a call like this&amp;nbsp;you could generate the SAS code to&amp;nbsp;create a copy of SASHELP.CLASS to the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%ds2post(sashelp.class);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you can just copy and paste.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class(label="Student Data" );
  attrib Name length=$8 ;
  attrib Sex length=$1 ;
  attrib Age length=8 ;
  attrib Height length=8 ;
  attrib Weight length=8 ;
  infile datalines dsd dlm='|' truncover;
  input Name -- Weight ;
datalines4;
Alfred|M|14|69|112.5
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
Carol|F|14|62.8|102.5
Henry|M|14|63.5|102.5
James|M|12|57.3|83
Jane|F|12|59.8|84.5
Janet|F|15|62.5|112.5
Jeffrey|M|13|62.5|84
John|M|12|59|99.5
Joyce|F|11|51.3|50.5
Judy|F|14|64.3|90
Louise|F|12|56.3|77
Mary|F|15|66.5|112
Philip|M|16|72|150
Robert|M|12|64.8|128
Ronald|M|15|67|133
Thomas|M|11|57.5|85
William|M|15|66.5|112
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Aug 2018 12:45:36 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-08-08T12:45:36Z</dc:date>
    <item>
      <title>How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484870#M3344</link>
      <description>&lt;P&gt;Week after week many people post questions on the community boards without providing sample data in the form of a data step. Why don't they use Mark Jordan's (&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;'s) convenient &lt;STRONG&gt;%data2datastep&lt;/STRONG&gt; macro, which is presented in &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;'s well-received &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;library article&lt;/A&gt; from March 2016?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indeed, a post using %data2datastep ("as is") would contain the keyword &lt;FONT face="courier new,courier"&gt;datalines4&lt;/FONT&gt;. But it seems that merely 96 discussions among all threads from the last 12 months contain this keyword.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yesterday, a user who had been pointed to the library article &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Separating-last-visit-number-from-1624-total-visits-among-60/m-p/484308#M125743" target="_blank"&gt;wrote&lt;/A&gt;: "I don't understand that reading at all!"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me try to put myself in the position of a fictitious user with only very basic SAS knowledge and a non-IT background, reading the article.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The first paragraph mentions "SASHELP datasets". Someone who is learning SAS on the job might not have come across these datasets. Maybe a link to more information would be helpful (cf. &lt;A href="https://communities.sas.com/t5/SAS-Analytics-U/SASHELP-sample-data-sets-documentation/td-p/259588" target="_blank"&gt;this discussion&lt;/A&gt; from March 2016)?&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The second paragraph is about the "SAS macro", "SAS University Edition" and "your autoexec" -- three terms the beginner might not be familiar with -- and the "macro call" follows. For someone who has never "called" a SAS macro (or who has been discouraged from using macros as a beginner) this could sound intimidating.&lt;BR /&gt;&lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; Would it help to avoid the term "macro" (until later in the article) and limit the explanations to plain instructions like "click there, copy that, ..."?&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The 6-step instructions start with a download link, don't they? &lt;EM&gt;No,&lt;/EM&gt; it's a link to another article (Mark Jordan's blog post). Only at the end of Mark's&amp;nbsp;post (not at the bottom of that page) there are download links. &lt;EM&gt;Two&lt;/EM&gt; of them! "Original" and "latest update".&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; Put &lt;EM&gt;one&lt;/EM&gt;&amp;nbsp;link &lt;EM&gt;directly&lt;/EM&gt; into Reeza's article without even mentioning "macros", "versions" or "updates". (See item 8 below, though.)&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Now I've downloaded a zip file. Not sure why it has to be a &lt;EM&gt;zip&lt;/EM&gt; file as it contains a &lt;EM&gt;single&lt;/EM&gt; .sas file of only &lt;EM&gt;3 or 5 KB&lt;/EM&gt;.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; Simply provide a link to a &lt;EM&gt;.sas &lt;/EM&gt;file (if at all, see item &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; -- no need for "extraction".&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The next two and a half steps are intended to users of SAS UE. Other users may feel lost.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; If necessary after the below simplifications, SAS could write similar instructions for other common scenarios, most notably a &lt;EM&gt;standard SAS session&lt;/EM&gt;. (I don't know if SAS EG, Viya, Studio, etc. would require different instructions.)&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;While it is convenient in some situations to use the Autoexec feature, it is not necessary here.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; Simplify the process as much as possible (with an impatient first-time user in mind). Autoexec can be suggested in a footnote.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;It can happen (especially after implementing item 4 above) that people &lt;EM&gt;open&lt;/EM&gt; the downloaded .sas file -- and are overwhelmed by 90+ lines of macro code. (This happened to user Tauqeer, who commented on Mark's blog post.)&lt;BR /&gt; To make this less likely, we could hide the macro code and just supply a short download program which could look something like this (draft code):&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _d2d url 'http://.../data2datastep.sas';
filename _prg temp;

data _null_;
infile _d2d;
file _prg;
input;
put _infile_;
run;

%inc _prg;

%data2datastep(!HELP)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;The above program being so short, we could &lt;EM&gt;do entirely without a download link&lt;/EM&gt; (thus avoiding a psychological hurdle for some people), put these few lines into a code box and say: "Run this program."&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Macro %data2datastep should not issue warning messages under normal circumstances. Currently, the harmless "&lt;FONT face="courier new,courier" color="#008000"&gt;WARNING: The quoted string currently being processed has become more than 262 characters ...&lt;/FONT&gt;" can occur if the user's dataset has many variables.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; To suppress the warning, set system option &lt;FONT face="courier new,courier"&gt;NOQUOTELENMAX&lt;/FONT&gt; and at the end restore it to what it was before (option value saved using&amp;nbsp;&lt;FONT face="courier new,courier"&gt;getoption&lt;/FONT&gt; at the start).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Currently, %data2datastep creates a text file in a user-specified or default location. So, the user is supposed to know this location, navigate to it and open the file manually.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; Let %data2datastep open this file &lt;EM&gt;automatically&lt;/EM&gt;. In a standard SAS Display Manager session this could be done with a DM command:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm 'filepad "&amp;amp;file"';&lt;/CODE&gt;&lt;/PRE&gt;
But this might not work in SAS UE (?).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Suggestions to simplify the macro call (i.e. create a "light" version of %data2datastep with fewer parameters):&lt;BR /&gt;a)&amp;nbsp;The user's&amp;nbsp;text&amp;nbsp;file could always be created with a fixed name in a new&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/establishing-additional-quot-work-quot-libraries/m-p/477975#M123191" target="_blank"&gt;subfolder of the WORK directory&lt;/A&gt;.&lt;BR /&gt;b)&amp;nbsp;The existing macro parameter &lt;FONT face="courier new,courier"&gt;dsn&lt;/FONT&gt; already accepts both one-level and two-level dataset names, thus making parameter &lt;FONT face="courier new,courier"&gt;lib&lt;/FONT&gt; dispensable.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;With only two macro parameters left (after implementing item 11) -- &lt;FONT face="courier new,courier"&gt;dsn&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;obs&lt;/FONT&gt; --, usage instructions for %data2datastep could be fairly short. (Cf. those given by SAS Jedi himself in his reply to the above-mentioned user Tauqeer.)&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Without parameter &lt;FONT face="courier new,courier"&gt;outlib&lt;/FONT&gt; (from version 2 of %data2datastep) there is a risk of inexperienced users overwriting a permanent dataset with the first few observations of it.&lt;BR /&gt; &lt;STRONG&gt;Suggestion:&lt;/STRONG&gt; The output dataset could always be named &lt;FONT face="courier new,courier"&gt;have&lt;/FONT&gt; -- the user can still edit the name manually.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be clear, this is not meant as a criticism. I was just wondering why %data2datastep is so underused.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 18:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484870#M3344</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-07T18:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484874#M3345</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;, your post is timely. I'm literally working on plans for a new SAS user forum where content like this would be *very* well received. We want the space to be exceptionally welcoming and helpful for folks trying to get up to speed on SAS, whether they're students or someone encountering SAS for the first time in the context of their job. I'd appreciate ideas from you and fellow members on ways to make it awesome.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 19:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484874#M3345</guid>
      <dc:creator>BeverlyBrown</dc:creator>
      <dc:date>2018-08-07T19:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484877#M3346</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote "&lt;SPAN&gt;&amp;nbsp;I was just wondering why %data2datastep is so underused"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Feedback from my fellow DePaul university College of computing&amp;nbsp; class and lab mates, they don't even know such a thing existed. That never came up as a pop up or an alert for newbies.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 19:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484877#M3346</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-08-07T19:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484884#M3348</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;: Sure, this can be another reason. However, before writing my post I had checked the "&lt;A href="https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles" target="_blank"&gt;Getting Started&lt;/A&gt;" page and found a link to Reeza's library article in the very first entry of that page, titled "&lt;A href="https://communities.sas.com/t5/Getting-Started/How-to-get-fast-helpful-answers/ta-p/226133" target="_blank"&gt;How to get fast, helpful answers&lt;/A&gt;&lt;SPAN&gt;" (in item 3 of "3 steps to compose a great question"). The latter is also linked at the bottom of the "New Message" screen (under the checklist "Before pressing POST ..."). So, the information is only one or two clicks away. But of course, new users of the Communities can arrive on a variety of routes. Maybe they could be guided a little more.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 19:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484884#M3348</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-07T19:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484924#M3349</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;: I agree with almost everything you said.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Three additional possible problems:&amp;nbsp;(1) the macro doesn't use named parameters (which would make it a lot easier [IMHO] to use; (2) there isn't an example usage line; and (3) one parameter isn't defined in the local parameters list thus produces a warning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I've corrected them in the following (which also includes the&amp;nbsp;NOQUOTELENMAX parameter adjustment:&lt;/P&gt;
&lt;PRE&gt;%macro data2datastep(dsn=,lib=,outlib=,file=,obs=,fmt=,lbl=);
%local varlist fmtlist LBLLIST inputlist msgtype NQLM;

%let NQLM=%sysfunc(getoption(NOQUOTELENMAX));

%if %superq(obs)= %then %let obs=MAX;

%let msgtype=NOTE;
%if %superq(dsn)= %then %do;
   %let msgtype=ERROR;
   %put &amp;amp;msgtype: You must specify a data set name;
   %put;
   %goto syntax;
%end;
%let dsn=%qupcase(%superq(dsn));
%if %superq(dsn)=!HELP %then %do;
%syntax:
   data _null_;
      call symput ('LS',getoption('LS','startupvalue'));
   run;
   options ls=100;
   options noquotelenmax;
   %put &amp;amp;msgtype: &amp;amp;SYSMACRONAME macro help document:;
   %put &amp;amp;msgtype- Purpose: Converts a data set to a SAS DATA step.;
   %put &amp;amp;msgtype- Syntax: %nrstr(%%)&amp;amp;SYSMACRONAME(dsn&amp;lt;,lib,outlib,file,obs,fmt,lbl&amp;gt;);
   %put &amp;amp;msgtype- dsn:    Name of the dataset to be converted. Required.;
   %put &amp;amp;msgtype- lib:    LIBREF of the original dataset. (Optional - if DSN is not fully qualified);
   %put &amp;amp;msgtype- outlib: LIBREF for the output dataset. (Optional - default is WORK);
   %put &amp;amp;msgtype- file:   Fully qualified filename for the DATA step code produced. (Optional);
   %put &amp;amp;msgtype-         Default is %nrstr(create_&amp;amp;outlib._&amp;amp;dsn._data.sas) in the SAS default directory.;
   %put &amp;amp;msgtype- obs:    Max observations to include the created dataset.;
   %put &amp;amp;msgtype-         (Optional) Default is MAX (all observations);
   %put &amp;amp;msgtype- fmt:    Format the numeric variables in the output dataset like the original data set? ;
   %put &amp;amp;msgtype-         (YES|NO - Optional) Default is YES;
   %put &amp;amp;msgtype- lbl:    Reproduce column labels in the output dataset? ;
   %put &amp;amp;msgtype-         (YES|NO - Optional) Default is YES;
   %put;
   %put NOTE:   &amp;amp;SYSMACRONAME cannot be used in-line - it generates code.;
   %put NOTE-   Every FORMAT in the original data must have a corresponding INFORMAT of the same name.;
   %put NOTE-   Data set label is automatically re-created.;
   %put NOTE-   Only numeric column formats can be re-created, character column formats are ingnored.;
   %put NOTE-   Use !HELP to print these notes.;
   options ls=&amp;amp;ls;
   %return;
%end; 
%if %superq(fmt)= %then %let fmt=YES;
%let fmt=%qupcase(&amp;amp;fmt);
%if %superq(lbl)= %then %let lbl=YES;
%let lbl=%qupcase(&amp;amp;lbl);

%if %superq(lib)= %then %do;
    %let lib=%qscan(%superq(dsn),1,.);
    %if %superq(lib) = %superq(dsn) %then %let lib=WORK;
    %else %let dsn=%qscan(&amp;amp;dsn,2,.);
%end;
%if %superq(outlib)= %then %let outlib=WORK;
%let lib=%qupcase(%superq(lib));
%let dsn=%qupcase(%superq(dsn));

%if %sysfunc(exist(&amp;amp;lib..&amp;amp;dsn)) ne 1 %then %do;
   %put ERROR: (&amp;amp;SYSMACRONAME) - Dataset &amp;amp;lib..&amp;amp;dsn does not exist.;
   %let msgtype=NOTE;
   %GoTo syntax;
%end;

%if %superq(file)= %then %do;
   %let file=create_&amp;amp;outlib._&amp;amp;dsn._data.sas;
   %if %symexist(USERDIR) %then %let file=&amp;amp;userdir/&amp;amp;file;
%end;

%if %symexist(USERDIR) %then %do;
   %if %qscan(%superq(file),-1,/\)=%superq(file) %then
      %let file=&amp;amp;userdir/&amp;amp;file;
%end;

proc sql noprint;
select Name
      into :varlist separated by ' '
   from dictionary.columns
   where libname="&amp;amp;lib"
     and memname="&amp;amp;dsn"
;
select case type
          when 'num' then 
             case 
                when missing(format) then cats(Name,':32.')
                else cats(Name,':',format)
             end 
          else cats(Name,':$',length,'.')
       end
      into :inputlist separated by ' '
   from dictionary.columns
   where libname="&amp;amp;lib"
     and memname="&amp;amp;dsn"
;
%if %qsubstr(%superq(lbl),1,1)=Y %then %do;
select strip(catx('=',Name,put(label,$quote.)))
   into : lbllist separated by ' '
   from dictionary.columns 
   where libname="&amp;amp;lib"
     and memname="&amp;amp;dsn"
     and label is not null 
;
%end;
%else %let lbllist=;
select memlabel 
   into :memlabel trimmed
   from dictionary.tables
   where libname="&amp;amp;lib"
     and memname="&amp;amp;dsn"
;
%if %qsubstr(%superq(fmt),1,1)=Y %then %do;
select strip(catx(' ',Name,format))
      into :fmtlist separated by ' '
   from dictionary.columns
   where libname="&amp;amp;lib"
     and memname="&amp;amp;dsn"
     and format is not null 
     and format not like '$%'
;
%end;
%else %let fmtlist=;
quit;

%put _local_;

data _null_;
   file "&amp;amp;file" dsd;
   if _n_ =1 then do;
   %if %superq(memlabel)= %then %do;
      put "data &amp;amp;outlib..&amp;amp;dsn;";
   %end;
   %else %do;
      put "data &amp;amp;outlib..&amp;amp;dsn(label=%tslit(%superq(memlabel)));";
   %end;
      put @3 "infile datalines dsd truncover;";
      put @3 "input %superq(inputlist);";
   %if not (%superq(fmtlist)=) %then %do;
      put @3 "format %superq(fmtlist);";
   %end;
   %if not (%superq(lbllist)=) %then %do;
      put @3 "label %superq(lbllist);";
   %end;
      put "datalines4;";
   end;
   set &amp;amp;lib..&amp;amp;dsn(obs=&amp;amp;obs) end=last; 
   put &amp;amp;varlist @;
   if last then do;
      put;
      put ';;;;';
   end;
   else put;
run;
options &amp;amp;NQLM.;
%mend;

/*
example usage:

%data2datastep(dsn=sashelp.class, file=/folders/myfolders/makeclass.sas)
*/
&lt;/PRE&gt;
&lt;P&gt;I, too, would like the resulting code to open up a window, but that particular set of dm commands doesn't work on SAS UE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&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;</description>
      <pubDate>Tue, 07 Aug 2018 22:38:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484924#M3349</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-07T22:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484931#M3350</link>
      <description>&lt;P&gt;What type of code should the macro generate?&lt;/P&gt;
&lt;P&gt;How much work should go into making the macro replicate exactly the input dataset versus making a macro that is easy to use and understand?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS.&amp;nbsp; Just because the parameters are defined as positional does NOT mean that you can't call them using their names.&amp;nbsp; One of the nicest usability features of SAS macros. Positional parameters should be used when it is "obvious" what the argument (or at least the main argument) to the macro is. In this case that would be the name of the dataset to replicate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ds2post
/----------------------------------------------------------------------------
Generate data step to post content of dataset on SAS Communities
----------------------------------------------------------------------------*/
(data  /* Name of dataset to post */
....
);
....
%mend ds2post ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 22:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484931#M3350</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-07T22:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484933#M3351</link>
      <description>&lt;P&gt;Speaking of UE how about adding this functionality as one of the default set of tasks that is included with SAS/Studio?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 22:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484933#M3351</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-07T22:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484948#M3352</link>
      <description>&lt;P&gt;Here is what I mean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say we had a simple macro like this.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;** UPDATED **&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ds2post
/*----------------------------------------------------------------------------
Generate data step to post content of dataset on SAS Communities
----------------------------------------------------------------------------*/
(data     /* Name of dataset to post *REQ*  */
,target=  /* Name to use in generated data step. (default is memname of &amp;amp;DATA) */
,obs=20   /* Number of observations to generate */
,file=log /* Fileref or quoted physical name of file to hold generated code */
,format=  /* Optional format list to use when generating data lines */
);
%local _error;
%*---------------------------------------------------------------------------
Check user parameters.
----------------------------------------------------------------------------;
%let _error=0;
%if "%upcase(%qsubstr(&amp;amp;data,1,2))" = "-H" %then %let _error=1;
%else %if %length(&amp;amp;data) %then %do;
  %if not (%sysfunc(exist(%qscan(&amp;amp;data,1,())))
        or %sysfunc(exist(%qscan(&amp;amp;data,1,()),view))) %then %do;
    %let _error = 1;
    %put ERROR: "&amp;amp;data" is not a valid value for the DATA parameter.;
    %put ERROR: Unable to find the dataset. ;
  %end;
%end;
%else %do;
  %let _error = 1;
  %put ERROR: The DATA parameter is required.;
%end;
%if not %length(&amp;amp;target) %then %let target=%qscan(%qscan(&amp;amp;data,1,()),-1,.);
%if not %length(&amp;amp;obs) %then %let obs=20;
%else %let obs=%upcase(&amp;amp;obs);
%if "&amp;amp;obs" ne "MAX" %then %if %sysfunc(verify(&amp;amp;obs,0123456789)) %then %do;
  %let _error = 1;
  %put ERROR: "&amp;amp;obs" is not a valid value for the OBS parameter.;
  %put ERROR: Valid values are MAX or non-negative integer. ;
%end;
%if not %length(&amp;amp;file) %then %let file=log;

%if (&amp;amp;_error) %then %do;
*----------------------------------------------------------------------------;
* When there are parameter issues then write instructions to the log. ;
*----------------------------------------------------------------------------;
data _null_;
  put
  '%DS2POST'
//'SAS macro to copy data into a SAS Data Step in a '
  'form which you can post to on-line forums.'
//'Syntax:'
/ ' %ds2post(data=,target=,obs=,format=,file=)'
//' data   = Name of SAS dataset (or view) that you want to output.'
//' target = Name to use for generated dataset.'
  ' Default is to use name of the input.'
//' obs    = Number of observations to output. Use MAX to copy complete dataset.'
  ' Default is 20.'
//' file   = Fileref or quoted physical filename for code.'
  ' Default is the SAS log.'
//' format = Optional list of &amp;lt;var_list&amp;gt; &amp;lt;format spec&amp;gt; pairs to use when writing'
  ' data lines.' ' Setting format=_all_ will clear all formats so raw data'
  ' values are written.'
//'Note that this macro will NOT work well for really long data lines.'
 /'If your data has really long variables or a lot of variables then consider'
  ' splitting your dataset in order to post it.'
  ;
run;
%end;
%else %do;
*----------------------------------------------------------------------------;
* Get contents information and sort by VARNUM ;
*----------------------------------------------------------------------------;
proc contents noprint data=&amp;amp;data
  out=_contents_(keep=name varnum type length format: inform: memlabel label)
;
run;
proc sort data=_contents_ ;
  by varnum;
run;
*----------------------------------------------------------------------------;
* Generate top of data step ;
*----------------------------------------------------------------------------;
filename _code_ temp;
data _null_;
  length firstvar name $60 string $300 ;
  retain firstvar ;
  file _code_ column=cc ;
  set _contents_ end=eof ;
  if _n_=1 then do;
    put "data &amp;amp;target" @;
    if not missing(memlabel) then do;
      string=quote(trim(memlabel),"'");
      put '(label=' string ')' @;
    end;
    put ';';
  end;
  name=nliteral(name) ;
  if _n_=1 then firstvar=name;
  string=cats(ifc(type=2,'$',' '),length);
  put '  attrib ' name 'length=' string @;
  if formatl or not missing(format) then do;
     string=cats(format,ifn(formatl,formatl,.),'.',ifn(formatd,formatd,.));
     put 'format=' string @ ;
  end;
  if informl or not missing(informat) then do;
     string=cats(informat,ifn(informl,informl,.),'.',ifn(informd,informd,.));
     if cc+9+length(string)&amp;gt;80 then put / @4 @ ;
     put 'informat=' string @ ;
  end;
  if not missing(label) then do;
     string=quote(trim(label),"'");
     if cc+7&amp;gt;80 then put / @4 'label=' string @ ;
     else if cc+7+length(string)&amp;gt;80 then put 'label=' / @4 string @ ;
     else  put 'label=' string @;
  end;
  put ';' ;
  if eof then do;
     put "  infile datalines dsd dlm='|' truncover;" ;
     put '  input ' firstvar '-- ' name ';';
     put 'datalines4;' ;
  end;
run;
*----------------------------------------------------------------------------;
* Generate data lines ;
*----------------------------------------------------------------------------;
data _null_;
  file _code_ mod dsd dlm='|';
%if (&amp;amp;obs ne MAX) %then %do;
  if _n_ &amp;gt; &amp;amp;obs then stop;
%end;
  set &amp;amp;data ;
%if %length(&amp;amp;format) %then %do;
  format &amp;amp;format;
%end;
  put (_all_) (+0) ;
run;
data _null_;
  file _code_ mod ;
  put ';;;;';
run;
  %if "%qupcase(&amp;amp;file)" ne "_CODE_" %then %do;
*----------------------------------------------------------------------------;
* Copy generated code to target file name ;
*----------------------------------------------------------------------------;
data _null_ ;
  infile _code_;
  file &amp;amp;file ;
  input;
  put _infile_;
run;
  %end;
%end;
%mend ds2post ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So with a call like this&amp;nbsp;you could generate the SAS code to&amp;nbsp;create a copy of SASHELP.CLASS to the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%ds2post(sashelp.class);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you can just copy and paste.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class(label="Student Data" );
  attrib Name length=$8 ;
  attrib Sex length=$1 ;
  attrib Age length=8 ;
  attrib Height length=8 ;
  attrib Weight length=8 ;
  infile datalines dsd dlm='|' truncover;
  input Name -- Weight ;
datalines4;
Alfred|M|14|69|112.5
Alice|F|13|56.5|84
Barbara|F|13|65.3|98
Carol|F|14|62.8|102.5
Henry|M|14|63.5|102.5
James|M|12|57.3|83
Jane|F|12|59.8|84.5
Janet|F|15|62.5|112.5
Jeffrey|M|13|62.5|84
John|M|12|59|99.5
Joyce|F|11|51.3|50.5
Judy|F|14|64.3|90
Louise|F|12|56.3|77
Mary|F|15|66.5|112
Philip|M|16|72|150
Robert|M|12|64.8|128
Ronald|M|15|67|133
Thomas|M|11|57.5|85
William|M|15|66.5|112
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 12:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484948#M3352</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-08T12:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484952#M3353</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: I agree!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 23:49:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/484952#M3353</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-07T23:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485066#M3355</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;: Many thanks for taking the time to read my lengthy post and for responding not only with a couple of remarks but even with full-grown updates of the macro! I'm sure in many companies the revision of a (non-trivial) standard macro would be considered more time-consuming.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My primary focus was on the library article. I didn't scrutinize&amp;nbsp;%data2datastep. My suggested code changes were just a "by-product" of a few test runs of the macro, which I had never used before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think ease of use is of paramount importance in this case. So, I'm in favor of a macro that covers the majority of use cases with only one or two parameters (preferably positional parameters). Good idea,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, to write the code to the log by default. I was hesitant to suggest this because of the line size limitation. (Actually,&amp;nbsp;one could temporarily set LS=MAX, i.e. 256.) But with the optional parameter specifying a physical file there is an effective solution for wide datasets.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 10:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485066#M3355</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-08T10:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485073#M3356</link>
      <description>&lt;P&gt;All of this is great, I hope whatever steps are taken are very successful, and I wish you the best. However, you can mark me down as pessimistic at best.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been involved in many on-line communities (and am still involved in many on-line communities). Each one has an article instructing beginners that they need to first search, and if you can't find what you are looking for, then provide specific information and state their problem clearly, &lt;EM&gt;etc. etc.&lt;/EM&gt;&amp;nbsp;There have been long discussions about what to do about this, and efforts put forth to make this information easily available to users. I doubt that these efforts have ever made a difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is an ongoing frustration for me (and probably for others) when people don't explain their problem clearly, sometimes don't even ask a clear question; they don't state what software they are using or what operating system they are using. In SAS, people have to be told to do things the way we want, because they don't know, they don't care and they won't care, they just want their answer. I doubt that an instruction document or a more welcoming user experience will change this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An amusing story:&lt;/P&gt;
&lt;P&gt;In another on-line forum, a user wrote something like this: "My software won't launch. It launched fine yesterday". That was the entire message. The response, which got many "likes", was "Your mouse is broken."&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 12:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485073#M3356</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-08T12:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485203#M3357</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;: Regarding your anecdote thought you mind find one of my own actual experiences amusing. A couple of years ago I couldn't figure out why I wasn't able to make a full system backup of my machine. My wireless mouse was working perfectly.&lt;/P&gt;
&lt;P&gt;After hours of futility,&amp;nbsp;and I can't recall why I did it, but replacing the wireless mouse with a non-wireless one, was all that was needed for the backup to work correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 16:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485203#M3357</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-08T16:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485205#M3358</link>
      <description>&lt;P&gt;Thanks a lot, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;.&amp;nbsp;I'm not too optimistic either. Still, improvements to the user experience are always a good thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand your frustration with all these imprecise problem descriptions. Apparently, there is a correlation between the ability to describe a problem accurately and the ability to solve this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it help to add (mandatory) checkboxes or drop-down lists (for SAS version etc.) to the "New Message" field?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 16:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485205#M3358</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-08-08T16:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485214#M3359</link>
      <description>&lt;P&gt;I'd say someone at SAS should just slip&amp;nbsp;&lt;SPAN&gt;data2datastep.sas into default autocall library installed during the build of the next maintenance release.&amp;nbsp; Even if you call it pre-release or experimental or whatever.&amp;nbsp; Of course it will be years until 50% of SAS users are on that release, but I think it would pay off in the long run.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Idea of downloading via URL is nice, but many folks working on servers (or even PC's) behind firewalls my not have access to the web.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I will admit that I don't use this macro enough myself.&amp;nbsp; I often end up typing a little CARDS data step by hand, and I'm surprisingly bad at that, even after 20 years...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 16:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485214#M3359</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-08-08T16:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485219#M3360</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks a lot, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;.&amp;nbsp;I'm not too optimistic either. Still, improvements to the user experience are always a good thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand your frustration with all these imprecise problem descriptions. Apparently, there is a correlation between the ability to describe a problem accurately and the ability to solve this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it help to add (mandatory) checkboxes or drop-down lists (for SAS version etc.) to the "New Message" field?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I'm sure it would help some, just like when you submit a ticket to SAS tech support, you have to specify operating system and version of SAS and a few other things. You can't submit the ticket without that information. And it ought to be configured so that if a user submits this information once in the SAS communities, it is remembered for the future until the user changes it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But there are other information needed that won't fit into checkboxes or dropdown lists. I suppose you could enforce somehow that all data must be in the form of a SAS data step, or pre-defined SAS data set (like SASHELP.CLASS), but then you get into the territory where users will be unhappy that they just can't ask a simple question without all of these intrusive requirements, and I don't think that's good.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 16:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485219#M3360</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-08T16:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485234#M3361</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is what I mean.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say we had a simple macro like this.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;** UPDATED **&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;updated macro deleted I just wanted to be sure which topic I am responding to&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about instead of sending output to a file or log using file print to send to results?&lt;/P&gt;
&lt;P&gt;I don't use EG or Studio so I'm not sure if that would actually work for some of the users but if the output appeared in a place that they may be learning to expect output it might help. Especially for UE the whole concept of where you can put files seems confusing.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 17:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485234#M3361</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-08T17:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485242#M3362</link>
      <description>&lt;P&gt;Wow - you guys are REALLY thinking about how to make this easy for a new user!&amp;nbsp; Thanks for all the thought put into this. I'm working on a new post with a slightly modified version of the macro to make it easier to use right out of the box. I've stolen prolifically from the suggestions here.&amp;nbsp; The idea of hosting the program file on http so that it was directly accessible was brilliant. I have a prototype up right now for testing.&amp;nbsp; Feel free to test and comment, but please don't formalize this - the URL will probably change when this goes live. Here's the code a new user would run to get set up:&lt;/P&gt;
&lt;PRE lang="SAS"&gt;filename _d2d url 'http://blogs.sas.com/content/sastraining/files/2018/08/data2datastep.txt' debug; 
filename _prg temp;

data _null_;
   infile _d2d;
   file _prg;
   input;
   put _infile_;
run;

%include _prg;
filename _d2d;
filename _prg;

%data2datastep(!HELP)&lt;/PRE&gt;
&lt;P&gt;This produces the docs in the SAS log, but I've moved the "getting started quickly" help to the top, and the detailed syntax help to the bottom like this:&lt;/P&gt;
&lt;PRE&gt;NOTE: DATA2DATASTEP macro help document:

      Purpose: Writes a SAS DATA step program to re-create a SAS data set.

        Example - To create a SAS program to reproduce 10 rows of the dataset SASHELP.CARS,
                  writing the copy to the SAS WORK library (WORK.CARS), just run this code:

         %DATA2DATASTEP(CARS,SASHELP,WORK,10)


NOTE:  Use %DATA2DATASTEP(!HELP) to print this detailed help for this macro.

      Syntax: %DATA2DATASTEP(dsn&amp;lt;,lib,outlib,obs,file,fmt,lbl&amp;gt;)

      dsn:    Name of the dataset to be converted. Required.
      lib:    LIBREF of the original dataset. (Optional - if DSN is not fully qualified)
      outlib: (Optional) LIBREF for the output dataset. Default is WORK
      obs:    (Optional) Max observations to include the created dataset.
                Default is MAX (all observations)
      file:   (Optional) Fully qualified filename for the DATA step code produced.
                Default is create_&amp;amp;outlib._&amp;amp;dsn._data.sas in the SAS default directory:
                S:\Workshop
      fmt:    (Optional) Format the numeric variables like the original data set?
                (YES|NO) Default is YES
      lbl:    (Optional) Reproduce column labels in the output dataset?
                (YES|NO) Default is YES
&lt;/PRE&gt;
&lt;P&gt;Another minor mod is that, when finished creating code, the macro now reports where to find the program it created. For example, running this code:&lt;/P&gt;
&lt;PRE&gt;%DATA2DATASTEP(CARS,SASHELP,WORK,10)

&lt;/PRE&gt;
&lt;P&gt;produces this response in the SAS log:&lt;/P&gt;
&lt;PRE&gt;      *****************************************************************
       Your SAS program which creates WORK.CARS is ready at
       S:\Workshop/create_WORK_CARS_data.sas
      *****************************************************************
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tested this and it works in SAS University Edition, PC SAS and in SAS Enterprise Guide.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm eager to hear your thoughts and comments on how to make this better and simpler for the new user.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485242#M3362</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-08-08T19:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485246#M3363</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;, thanks for jumping on this thread and pulling these great ideas into a post! Write it as a library article and select the New SAS User label that I just created. That'll make it easy for me to steward and share this type of content later. Appreciate everyone sharing their POVs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 18:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485246#M3363</guid>
      <dc:creator>BeverlyBrown</dc:creator>
      <dc:date>2018-08-08T18:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485257#M3364</link>
      <description>&lt;P&gt;I am not a fan of keyword&amp;nbsp;parameters because the end user has to &lt;EM&gt;remember&lt;/EM&gt; the macro variable names and &lt;EM&gt;type them correctly&lt;/EM&gt; for every use. I prefer the simplicity of positional parameters combined with default values (provided in the macro code) and easy-to-use self documentation. It's probably more a matter of style and personal predilection.&amp;nbsp; I'm not a great 'rememberer', neither am I the world's best typist, so I have always personally found keyword parameters problematic.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485257#M3364</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2018-08-08T19:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can we popularize %data2datastep further?</title>
      <link>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485289#M3365</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;: Unfortunately, I'm not familiar with github but, from reading some posts, one apparently can upload a file there and have it saved as a RAW file, and such a file can be directly imported into SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully, someone who is familiar with github can explain what one has to do in order to use the raw url.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g., there is one at:&amp;nbsp;&lt;A href="https://raw.githubusercontent.com/SchmidtPaul/HeritabilityScripts/master/SAS/MACRO%20H2_Piepho.sas" target="_blank"&gt;https://raw.githubusercontent.com/SchmidtPaul/HeritabilityScripts/master/SAS/MACRO%20H2_Piepho.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with it, I think one can use:&lt;/P&gt;
&lt;P&gt;filename h2 url "&lt;A href="https://raw.githubusercontent.com/SchmidtPaul/HeritabilityScripts/master/SAS/MACRO%20H2_Piepho.sas" target="_blank"&gt;https://raw.githubusercontent.com/SchmidtPaul/HeritabilityScripts/master/SAS/MACRO%20H2_Piepho.sas&lt;/A&gt;";&lt;BR /&gt;%include h2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then simply call the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 21:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/How-can-we-popularize-data2datastep-further/m-p/485289#M3365</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-08-08T21:06:31Z</dc:date>
    </item>
  </channel>
</rss>

