Solved

Inputing a File in SAS and then Print it out

Posted on 2008-10-03
3
925 Views
Last Modified: 2013-11-16
I want to build a code for SAS that allows me to input a file and then print it out in a specific format.
DATA breas.art;
  INFILE '/apps/dataapps15/projects/dinhch/artfile.txt' DELIMITER=',' dsd lrecl=400 pad missover;
    INPUT  	   ICN  				 :$14.
               ICN_VRSN 		 :8.
               DOC_ID        :$15.
               ADJKEY 			 :$8.
               TTL_CHRG 		 :13.2
               PDATE 				 :$8.
               ADJ_TYPE_CD 	 :$2.
               ADJ_RSN_CD 	 :$3.
               UPD_USER 		 :$8.
               TTL_PAID_AMNT :13.2
               FUND_CODE		 :$13.			
               FUND	    		 :$154.;
 
Group by the ADJKEY , count the ICN and sum up the TTL_Paid_amnt
 
Print it out
 
example, the result file would be
ADJKEY	Count	Sum

Open in new window

0
Comment
Question by:lowkeyy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
andymcooper earned 500 total points
ID: 22640504
Lowkeyy,

I assume your importing code works? If so, try the following:



Note that proc means without a noprint in it will print out the result.

Or you could also run a proc print.

Andy

proc means data=BREAS.ART nway missing;
  /* Group by the ADJKEY */
  class ADJKEY;
  /* output result to a new dataset */
  output out=BREAS.ART_SUM (drop=_TYPE_)
           /* count the ICN and sum up the TTL_Paid_amnt */
             count(ICN) = COUNT
  	     sum(TTL_PAID_AMNT) = SUM;
run;

Open in new window

0
 

Expert Comment

by:Kumar1505
ID: 22820681
Hi Lowkeyy,

After importing the artfile.txt into SAS as "art", you can use either Means or Summary or SQL procedures to get what u need.

Proc sql;
create table breas.summarized as
select ADJkey,
          count(ICT) as cnt_ict,
          sum(ttl_paid_amt) as TTL_paid
from breas.art
group by ADJkey;
quit;

proc print data=breas.summarized ;
run;
0
 
LVL 5

Expert Comment

by:tobey1
ID: 23021970
I would use a PROC IMPORT (http://www.otago.ac.nz/sas/proc/z0308090.htm) to ge the data in, and then either Andy's code or Kumar's code for the display and creation of a SAS Stat file.
PROC IMPORT 
DATAFILE='/apps/dataapps15/projects/dinhch/artfile.txt' 
OUT=breas.art 
DBMS=CVS REPLACE;  

Open in new window

0

Featured Post

Upcoming Webinar: Percona XtraDB Cluster 6/21 10am

Join Percona’s MySQL Practice Manager Kenny Gryp and QA Engineer, Ramesh Sivaraman as they present Percona XtraDB Cluster, Galera Cluster, MySQL Group Replication on Wednesday, June 21, 2017 at 10:00 am PDT / 1:00 pm EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question