i write SAS code in IBM mainframe, i have to make out a report from the input file which is generally in Gov00 version.
this file has multiple contributions (in dollars) of the participant. like contribution type A , contribution type , contribution type c, i have to write a code through which i can pull out the detials of each contribution, like how many contribution is of type A and then their basic details like name , SSN, contribution type.
just give you the layout of the file
Please guide me on this.
infile a
input @001 SSN :09.
@013 Date :YYYYMMDD10
@26 Contribution A :15.
@42 contribtuion B ;15.
@56 contribution c :15
output
SSN | Date | Contribution A | ContribuionB | ContributionC | |
1.43E+08 | 9/3/2018 | 17.6 | 13.2 | 16.3 | |
3.57E+08 | 9/3/2018 | 13.5 | 14.6 | ||
1.23E+08 | 9/3/2018 | 14.5 | 17.2 | ||
4.59E+08 | 9/3/2018 | ||||
1.37E+08 | 9/3/2018 | 11.1 | 12.3 | ||
7.86E+08 | 9/3/2018 | 15.5 |
any help and guidance would be highly appreciable.
A few ideas to consider ...
First, don't use tools that you don't understand. I would bet real money that you don't know what a colon means. (In fact, I would bet that you understand very little of the INPUT statement and should take some time to try to understand how to read in a variable.)
Second, SSN should be a character field, not a numeric field. You are never going to add SSNs together or find the mean value of SSN. It represents a category, and thus should be character.
Third, variable names cannot contain spaces (unless you introduce complications to the program that make it clumsy to work with). So Contribution A is illegal, but Contribution_A would be perfectly fine.
Fourth, pay attention to the details. If Contribution_A starts at column 26 and occupies 15 characters, Contribution B should begin at column 41, not column 42.
Here is a rewritten INPUT statement to illustrate:
input @001 SSN $ 09.
@013 Date YYYYMMDD10.
@26 Contribution_A 15.
@41 contribtuion_B 15.
@56 contribution_c 15.
;
format date yymmdd10.;
A colon concept
http://www2.sas.com/proceedings/sugi26/p073-26.pdf
I find that if I do a search on things like SAS colon concept googol retrieve links such as the above link. This was the first returned ULR in my list that googol fetched for me.
the same searching concept also assist me when I need to finding out about how to use SAS proc sql or SAS proc transpose. I find that including SAS to start my search retrieves ULRs related to SAS and helps exclude other programing languages in the first set of search results.
What is the required report? Do you really want to report SSNs in scientific notation?
Do you know how to run a basic PROC PRINT?
Since you want to shift the decimal point in the numbers, here's a small change to the earlier suggestion:
input @001 SSN $ 09.
@013 Date YYYYMMDD10.
@26 Contribution_A 15.1
@41 contribtuion_B 15.1
@56 contribution_c 15.1
;
format date yymmdd10.;
But how are you expecting to accomplish your objective, when you don't know how to read in data and you don't know how to produce any type of a report and you don't even tell us what the report is supposed to look like?
RE 15386516, Urgent: Can I make a suggestion if those are real SSN's in your sample you better remove those numbers due to HIPAA rules.
First of all you don't share SSN's even in examples. You must protect confidential information.
https://www.hhs.gov/hipaa/for-professionals/privacy/laws-regulations/index.html
HHS and your employer may be in jeopardy if you are sharing those data information. HHS fronds on such action.
Second if you on a IBM mainframe working with GOV files you should have already know the above rules.
Third if you don't know those rules you should have already signed a none disclosure agreement with your employer before you could have started working with GOV files.
Fourth of all, help those coming behind you by know what you were hired for, if your statements are true.
Know your data. Know your obligation related to those data. Know how to mask and provide others knowledge that those SSN's are not true and have been masked or replaced to represent your needs and are not true SSN's.
Sharing of data, rules, forms, GOV.
@Best wrote:
No I don’t want the report in scientific notation , it is just ssn while copying from excel
That's where your problem starts. The Excel file format is utter crap for data interchange.
It forces SAS to make guesses about the data structure, depending on the contained data. Since it's quite hard to tell Excel that a 9-digit string is a string and not a number, you end up with faulty attributes in your dataset.
I'm actually surprised that someone working on a mainframe uses such files at all.
Have the data sent to you in a usable format (csv or fixed-width colums), and read that with a data step.
Also see Maxims 22, 27, 31.
Taking the text from your posted file, I ran this code:
data want;
input
@01 ssn $9.
@13 date yymmdd8.
@26 contribution_a 15.
@41 contribution_b 15.
@56 contribution_c 15.
;
format
date yymmddd10.
contribution_a
contribution_b
contribution_c
15.
;
datalines;
1425637560002018091200000000000000000176000000000000132000000000000163000000000000000000000000000000000000000000000000000
3568921370002018091200000000000000000000000000000000135000000000000146000000000000000000000000000000000000000000000000000
1234578900002018091200000000000000000145000000000000000000000000000172000000000000000000000000000000000000000000000000000
4587961230002018091200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1369785230002018091200000011100000000111000000000000123000000000000000000000000000000000000000000000000000000000000000000
7856391230002018091200000000000000000000000000000000000000000000000155000000000000000000000000000000000000000000000000000
;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.