Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Can Data Step Do it ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
joceyc...@hotmail.com  
View profile  
 More options Feb 9, 3:30 am
Newsgroups: comp.soft-sys.sas
From: joceyc...@hotmail.com
Date: Thu, 9 Feb 2012 00:30:37 -0800 (PST)
Local: Thurs, Feb 9 2012 3:30 am
Subject: Can Data Step Do it ?
Hi

if i have a file that looks like the following :

-----------------Start---------------
FIELD001
  LEGAL
    0
    1
    9
  END
  JUMPS
    1 FIELD555
  END
END

FIELD002
  RANGE 1 6
  LEGAL
    9
  END
END
------------------------THE END---------------

is there anyway for a data step to create such a formated report ?

Fieldname    Jump on           Jump to
========= ========     ===========
FIELD001     1                   FIELD555

by detecting the key work JUMPS in the file ?

thank you
Jocey


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ajs2004@bigfoot.com  
View profile  
 More options Feb 9, 11:53 am
Newsgroups: comp.soft-sys.sas
From: "ajs2...@bigfoot.com" <ajs2...@bigfoot.com>
Date: Thu, 9 Feb 2012 08:53:21 -0800 (PST)
Local: Thurs, Feb 9 2012 11:53 am
Subject: Re: Can Data Step Do it ?
Yes, that shouldn't be hard, but you need to give more information
about the data file structure.

Does the file _always_ have exactly this layout?
Could it have arbitrary numbers of FIELDxxx ... END groups?
Do we ignore everything between FIELDxxx ... END except JUPMPS ... END
(so we exclude, for example, LEGAL ... END and RANGE x)?
Are there ever further levels of nesting of <something> ... END ?
Does END occur in any other context?
Does JUMPS ... END ever contain anything in between other than  n
FIELDxxx?
So, can we match FIELDxxx ... END by relying on the structure of the
stuff in between?
Looks like we sometimes have one JUMPS in between FIELDxxx ... END and
sometimes none. Do we ever have more than one, and what should happen
then?

On Feb 9, 8:30 am, joceyc...@hotmail.com wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ajs2004@bigfoot.com  
View profile  
 More options Feb 9, 12:11 pm
Newsgroups: comp.soft-sys.sas
From: "ajs2...@bigfoot.com" <ajs2...@bigfoot.com>
Date: Thu, 9 Feb 2012 09:11:07 -0800 (PST)
Local: Thurs, Feb 9 2012 12:11 pm
Subject: Re: Can Data Step Do it ?
Here's an example program. Uses a DATA step to read the file, and PROC
PRINT to produce the report; you could use a data step for that as
well, if you really wanted to.

data;
  length word1 word2 field_name $8 jumps_on 8 jumps_to $8;
  infile datalines missover;
  input word1 word2;
  if (substr(word1, 1, 5)='FIELD') then field_name = word1;
  if (word1='JUMPS') then do;
    input jumps_on jumps_to;
    output;
  end;
  retain field_name;
  keep field_name jumps_on jumps_to;
  datalines;
FIELD001
  LEGAL
    0
    1
    9
  END
  JUMPS
    1 FIELD555
  END
END

FIELD002
  RANGE 1 6
  LEGAL
    9
  END
END
;
run;

options nocenter;

proc print;
run;

Output:

        field_
Obs      name      jumps_on    jumps_to

 1     FIELD001        1       FIELD555


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Barry Schwarz  
View profile  
 More options Feb 9, 1:59 pm
Newsgroups: comp.soft-sys.sas
From: Barry Schwarz <schwa...@dqel.com>
Date: Thu, 09 Feb 2012 10:59:50 -0800
Local: Thurs, Feb 9 2012 1:59 pm
Subject: Re: Can Data Step Do it ?

Is this what you mean
   The block of lines for a field start with FIELDnnn and stop at the
corresponding END
   Ignore everything between LEGAL and its corresponding END (just in
case the word JUMPS shows up there)
   For each line between JUMPS and its corresponding END, output the
field name, the condition, and the destination (in case there is more
than one line)

If so, the consider the following in a data step
   Retain variables saved_field, flag_legal, flag_jumps
   Read a line
   If flag_jumps
      If line is END
         Reset flag_jumps
      Else
         Output saved_field, condition, and destination
   Else if flag_legal
      If line is END
         Reset flag_legal
   Else
      If line is FIELDnnn
         Set save_field
      Else if line is LEGAL
         Set flag_legal
      Else if line is JUMPS
         Set flag_jumps

--
Remove del for email


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
joceyc...@hotmail.com  
View profile  
 More options Feb 9, 7:41 pm
Newsgroups: comp.soft-sys.sas
From: joceyc...@hotmail.com
Date: Thu, 9 Feb 2012 16:41:57 -0800 (PST)
Local: Thurs, Feb 9 2012 7:41 pm
Subject: Re: Can Data Step Do it ?
Thanks for all the help. I have managed to tweak both the codes
provided in this tread to get the required output.
I have a better understanding of data step now. Thank you very much
again.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »