SAS Macro and Dataline/Cards Statements in Data Step

I recently tried code like this in a SAS macro:

data sections;
        infile datalines dlm=”,”;
        input graph_table_number $15. text_line @1 @;
        datalines;
        “11.1           ,Section 11.1”,
        “11.2           ,Section 11.2”,
        “11.3           ,Section 11.3”
        ;
run;

While it works in its own right, including it as part of a macro yielded this type of result:

ERROR: The macro X generated CARDS (data lines) for the DATA step, which could cause incorrect results.  The DATA step and the macro will stop executing.

A bit of googling landed me on SAS-L where I spotted a solution like this one that didn’t involving throwing everything out:

filename temp temp;

data _null_;
        file temp;
        put;
run;

data sections;
        length graph_table_number $15 text_line $100;
        infile temp dlm=”,”;
        input @;
        do _infile_=
        “11.1           ,Section 11.1”,
        “11.2           ,Section 11.2”,
        “11.3           ,Section 11.3”
        ;
                input graph_table_number $15. text_line @1 @;
                output;
        end;
run;

filename temp clear;

The filename statement and ensuing data step creates a dummy file in the SAS work area that gets cleared at the end of every session. That seems to fool the macro engine into thinking that input is from a file and not the CARDS/DATALINES method to which it takes grave exception. The trailing @’s hold an input record for the execution of the next INPUT statement within the same iteration of the DATA step so that the automatic variable _infile_ can be fed as part of the input process in a do block with the output statement ensure that new records from the input buffer reach the data set being created.

This method does work but I would like to know the underlying reason as to why SAS Macro won’t play well with included data entry using DATALINES or CARDS statements in a data step, particularly when it allows other methods that using either SQL insert statements or standard variable assignment in data step. I find it such a curious behaviour that I remain on the lookout for the explanation why it is like this.

Alt-Click problems in Ubuntu-hosted VirtualBox Windows guests

Ubuntu Window Preferences

Ubuntu Window Preferences

The Alt-Click keyboard.mouse combination is a very common way of working with various flavours of Adobe Photoshop. So it was with some frustration that I couldn’t use it while working in Photoshop Elements (still on version 5, by the way; the temptation of newer versions has not struck) on a Windows XP guest in VirtualBox on my main Ubuntu system. A quick google later and a proposed solution was for me a surprising one: going to System->Preferences->Windows on the host OS and changing the setting of the Movement Key from Alt to Super (Windows key on many keyboards). That was enough to set all in order. It seems that a setting on the host operating system was preventing a piece of software running on the guest from behaving as expected. That’s all in the past now that I have got my clone brush functionality back and can work as normal again.

Another way to control line breaks in (X)HTML

While you can use <br /> tags, there is another way to achieve similar results: the &nbsp; or non-breaking space entity. Put one of them between two words and you stop them getting separated by a line break; I have been using this in the latest design tweaks that I made to my online photo gallery. Turning this on its head, if you see two words together acting without regard to normal wrapping conventions, then you can suspect that a non-breaking space could be a cause. There might be CSS options too but their effectiveness in different browsers may limit their usefulness.

Copying only updated and new files

With Linux/UNIX, the command line remains ever useful and allows you to do all manner of things, including file copying that only adds new files to a destination. Here’s a command that accomplishes this in Linux:

cp -urv [source] [destination]

The u switch does the update while r ensures recursion (by default, cp only copies files from a source directory and not anything sitting in subfolders) and v tells the command to tell the user what is happening.

Though buried and hardly promoted, Windows also has its command line and here’s what accomplishes a similar result:

xcopy /d /u [source] [destination]

Anything’s better than having to approve or reject every instance where source and destination files are the same or, even worse, to overwrite a file when it is not wanted.