BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rakesh1212
Fluorite | Level 6

Hi Kurt,

 

Thanks for your reply.

 

Since this is dynamic flow, i will not be hard coding the label. It has to be read from the copy book and then take the field name as label name. Attached is the screen shot which i initially pasted.

 

now i want label names attached in the screen shot to be printed.

 

Regards,

Rakesh MS


IMG_3846.JPGIMG_3848.JPG
Kurt_Bremser
Super User

Since we have already determined that the main attributes of the SAS variables cannot be reliably determined from the copybook, it does not make sense to just automate the labels. That's such a minor part of all the work that trying to automate it is just a waste of precious brain-cycles.

rakesh1212
Fluorite | Level 6
kurt,
How to display labels in the put statement.

label A20219 "x50978 nvcb trans hand fee ";

data _null_;
set temp1;
file sasout dlm="," dsd;
put (_all_) (+0);
run;
Kurt_Bremser
Super User

You have to write the headerline in the datastep in the way I already showed you.

You can retrieve the labels automatically like this:

proc sql noprint;
select label into :headerline separated by ','
from dictionary.columns
where upcase(libname) = "LIBRARY" and upcase(memname) = "DATASET";
quit;

The corresponding line of code in the datastep will then be:

if _n_ = 1 then put "&headerline";
rakesh1212
Fluorite | Level 6
Hi Kurt,

I am confused with the libarary name and dataset name. I have already have the label in my JCL(Just like below) control card. I want use them as label in the heading.


LABEL A0001 = "x50978D record ";
LABEL A0002 ="X50978D HD type ";
LABEL A0003 ="X50978D Account ";


Regards,
Rakesh MS
Kurt_Bremser
Super User

You use the library and dataset name of the dataset you create when you read the external file. The metadata of all datasets in all currently assigned libraries will dynamically appear in dictionary.columns.

Take the dataset & library name from the data statement of your current data step that reads the COBOL-originated file.

rakesh1212
Fluorite | Level 6
Kurt,

The file which is created doesn't have a header. Labels are with in the JCL only ( This is with in the job in control card)

I can print label to spool along with data conversion using below command but not able to write the same thing using ut statement
Proc print data = temp1 label noobs;

But i want tthe same thing to write it to the output file.

Regards,
Rakesh MS
Kurt_Bremser
Super User

To get the labels from dataset temp1 (no library given, so therefore that is a dataset in WORK), use

proc sql noprint;
select label into :headerline separated by ','
from dictionary.columns
where upcase(libname) = "WORK" and upcase(memname) = "TEMP1";
quit;

Then use &headerline in the if _n_ =1 then put ..... statement.

rakesh1212
Fluorite | Level 6
Hi kurt,

I was referring to label like below

Proc print data label noobs;

I want the similar syntax while writing to the output file using put statement.
Regards,
Rakesh MS

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 24 replies
  • 4890 views
  • 4 likes
  • 4 in conversation