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
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.
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";
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.
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.
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!
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.