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...

 

sas-innovate-2024.png

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.

 

Register now!

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