BookmarkSubscribeRSS Feed
Vani1493
Fluorite | Level 6
FILENAME datafile pipe "7z e /homes/data/natality/2017/natl2017.zip  -so ";

Can somebody explain why pipe statement is used in the above code and in the path why there is 7z e and at the end -so is used?

 

 

attrib  rf_ppterm    length=$1    label="Previous Preterm Birth Y Yes";

And also why attrib is used in the above code, what is the relationship between attrib and label (why Y yes is included in the code) 

 

 

3 REPLIES 3
ballardw
Super User

PIPE in a filename statement is telling SAS to request something from the operating system and then send the result in a form that SAS can use as a file, typically for reading. The options in the quotes depend on the operating system so 7z might be the name of an operating system command or program and the remainder would be the parameters that command or program uses so is OS and possibly installation specific. My guess from the name of file is that it is requesting a program to extract data from a Zip compressed file, possibly just a description of the contents a guess without searching out details of 7z.

 

The Attrib statement allows setting multiple attributes for a variable in one statement instead of using separate Length, Informat, Format and Label statements. The "why Y Yes" is because that is what the programmer wanted displayed for the label. Typically I would expect that more when the value was less obvious such as "1 Yes" or "Q Uknown" to describe one, or possibly more values, so the program and data documents some details of what the variables mean..

Vani1493
Fluorite | Level 6

Thank you so much for your valuable reply.  

 

attrib  rf_ppterm    length=$1    label="Previous Preterm Birth Y Yes"; 

 

I heard Attribs used as macro parameters and default is N...maybe that is the reason in the above statement mention Y yes.  If we did not mention Y yes, it will take only N No for the variable rf_ppterm?

 

I am very new to SAS, please help me.

 

Thank you

 

 

 

ballardw
Super User

@Vani1493 wrote:

Thank you so much for your valuable reply.  

 

attrib  rf_ppterm    length=$1    label="Previous Preterm Birth Y Yes"; 

 

I heard Attribs used as macro parameters and default is N...maybe that is the reason in the above statement mention Y yes.  If we did not mention Y yes, it will take only N No for the variable rf_ppterm?

 

I am very new to SAS, please help me.

 

Thank you


Labels are text that a programmer wants to appear in the places that a label would appear. Period. There does not have to be any relationship to the values at all. So if you remove the "Y yes" then the text displayed changes but there is no effect on the value.

 

Example:

data junk;
    x='abcdef';
   label x='The meaning of life. 42 is the answer';
run;

proc print data=junk label;
run;

If you run the above the Proc print displays the label and the value of x. See any actual connection?

This behavior of label has several pieces. One is label attached to a variable can be permanent, i.e. part of the data set description. But you can often override the default label by providing one just for the duration of a particular procedure:

proc print data=junk label;
   label x='Some random text';
run;

The above does not change the label associated with the variable X permanently, only for the duration of that procedure.

 

Typically a use for overriding a label may make more sense with a numeric variable where you have summarized it so want to change the label from something like "Account Ballance" to "Average account balance". You can let your imagination be your guide as needed. Another reason to override the label for a procedure may be that the text displayed is longer than you want to see for table or graph. So you could change the default label of a variable from a narrative "Count of chickens seen crossing road on Dec 7" to "# Chickens" if the "crossing the road on Dec 7" is not critical information at that point.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1215 views
  • 0 likes
  • 2 in conversation