LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 5 May 2005 15:06:04 -0700
Reply-To:     "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject:      Re: writing vars to a delimited file with tab
Comments: To: "Michael S. Zdeb" <msz03@HEALTH.STATE.NY.US>

Hi Mike -

One of my favorites is - put (_all_) (=/);

DATA _null_; SET SASHELP.CLASS; put (_all_) (=/); RUN;

.......SAS Log........ Name=Alfred Sex=M Age=14 Height=69 Weight=112.5

Name=Alice Sex=F Age=13 Height=56.5 Weight=84

Name=Barbara Sex=F Age=13 Height=65.3 Weight=98

.........etc........

Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Michael S. Zdeb Sent: Wednesday, May 04, 2005 1:55 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: writing vars to a delimited file with tab

Hi...there's a whole collection of "do nothing" entries that also work --- in addition to the (+0)...

put (_all_) (:) ; put (_all_) (&) ; put (_all_) (?) ;

and the even more mysterious...

put (_all_) (:&?+0);

PS How about a "most obscure kludge" award at the SAS-L BOF next year?

Mike Zdeb U@Albany School of Public Health 1 University Drive Rensselaer, NY 12144-3456 (P)518-402-6479 (F)630-604-1475

|---------+----------------------------> | | "Howard Schreier | | | <hs AT dc-sug DOT| | | org>" | | | Sent by: "SAS(r) | | | Discussion" | | | <SAS-L@LISTSERV.U| | | GA.EDU> | | | | | | | | | 05/04/2005 04:32 | | | PM | | | Please respond to| | | "Howard Schreier | | | <hs AT dc-sug DOT| | | org>" | | | | |---------+---------------------------->

>--------------------------------------------------------------------------- -----------------------------------| | | | To: SAS-L@LISTSERV.UGA.EDU | | cc: | | Subject: Re: writing vars to a delimited file with tab |

>--------------------------------------------------------------------------- -----------------------------------|

I've been asked to explain the +0 spec. Indeed it is an obscure kludge.

The key is to understand that the token

_all_

has two different meanings. First, it is a form of variable list. See the online doc:

Base SAS SAS Language Concepts SAS System Concepts SAS Variables SAS Variable Lists Special SAS Name Lists

Second, it is a permitted argument in a PUT statement. See:

Base SAS SAS Language Dictionary Dictionary of Language Elements Statements PUT Statement Arguments

So only in a PUT statement is there the possibility of ambiguity. SAS resolves the ambiguity by assuming the second usage when it sees a simple "_ALL_" in a PUT statement. As a consequence, Jamil's code triggered the second usage when he needed the first.

However, there is another bit of PUT statement syntax which can be used. See:

Base SAS SAS Language Dictionary Dictionary of Language Elements Statements PUT Statement, Formatted How to Group Variables and Formats

When "_ALL_" is used in such grouping, it is as a list. The notation involves parentheses:

put (_all_);

The compiler does not accept this; it also wants the second pair of parentheses, which serves as the container for the formats and pointer controls. So make it:

put (_all_)();

Still no good; it wants something in that container. Since we really don't want or need any formats or pointer controls, just drop in a pointer control which does nothing:

put (_all_)(+0);

So the +0 is there to make the compiler happy and then to do absolutely nothing during execution.

On Tue, 3 May 2005 21:29:11 -0400, Howard Schreier <hs AT dc-sug DOT org> <nospam@HOWLES.COM> wrote:

>Just change the PUT statement to > > put (_all_)(+0); > >On Tue, 3 May 2005 18:09:38 -0500, Jamil Ibrahim ><jibrahim@ACADAFF.UMSMED.EDU> wrote: > >>Hi how cat I write the data out without the var= with tabs as >>delimiters >>here is my code: >>DATA TEST; >> infile "c:\bubble\myforms\evers\ho\hophd03.dat" LRECL=114 MISSOVER >>PAD; >>input @1 q1 $1. @2 prog $char4. @6 yrs $char3. @9 (q2-q23) ($1.) >> @31 address $1. @33 year $char4.; >> >> >> >> FILE "A:HOPHD_A.DAT" DLM='09'X ; >> >>PUT _ALL_ ; >>RUN; >> >> >> >>Dr. Jamil Ibrahim, Ph.D. >>Institutional Research Associate >>Assistant Professor , SHRP >>Univ. Of Miss. Med. CTR. >>2500 N state St >>Jackson, MS 39216 >>Tel. 601-984-1197 >>Fax 601-984-1205 >>Nternet: jibrahim@acadaff.umsmed.edu


Back to: Top of message | Previous page | Main SAS-L page