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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.