Hi,
I am reading few values from a input dataset, using SAS in mainframes.
And while writing to the output dataset, I need to add titles/header/labels(not sure what we is the exact syntax in sas) for those fields.
For example:
Input file layout:
LA ,80002,1942,1040
LA ,80002,1842,1940
LA ,80004,1713,1510
output file should be as follows: File should have first record as description/title/label for the upcoming records: Kinda of title for all those fields
AREA, LOC , CC ,DEPT
LA ,80002,1942,1040
LA ,80002,1842,1940
LA ,80004,1713,1510
I cant try proc print, because I am writing all records to a output dataset and not in sas log.
Also if i use
proc print data=infile1 label;
label area='AREA1';
run;
I am getting spaces between all those Fields.
Please help.
Hi, this only works if all the variables are defined as character.
data test1;
length AREA LOC CC DEPT $20;
input area loc cc dept;
datalines;
LA 80002 1942 1040
LA 80002 1842 1940
LA 80004 1713 1510
run;
proc contents data = test1 out = cont (keep = name) ; run;
proc transpose data = cont out = vars (drop = _name_ _label_);
id name;
var name;
run;
data test2;
set vars test1;
run;
Looks like you are just writng a CSV file. You can try using PROC EXPORT. Or you can just do it with a data step.
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.