BookmarkSubscribeRSS Feed
Santhoshcsc
Calcite | Level 5

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.

2 REPLIES 2
evp000
Quartz | Level 8

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;

 

 

Tom
Super User Tom
Super User

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.

https://communities.sas.com/t5/General-SAS-Programming/Exporting-CSV-File-Using-dsd-option-and-Getti...

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 959 views
  • 0 likes
  • 3 in conversation