DATA Step, Macro, Functions and more

Need help with writting out a file to a dataset

Accepted Solution Solved
Reply
Contributor
Posts: 39
Accepted Solution

Need help with writting out a file to a dataset

I am having a weird issue with the space in place of zeros for a varaible when I write out to a mf dataset. I get a variable and its value calling a IMS db in a data step, I am using same variable in another data step and the same varaible when I write out to a mainframe dataset  is changing to a space.

 

Following is the sas code i used..

 

data have;,,
  infile intxn;
  input
@001 txns_rec $238.
@001 srvcr $6. @007 lnno $9. ... ... ... @161 slrname $30. ... ... run;

 I am getting couple of variables (groupno & lnany) from IMS db like below

 

 

***************************************************************;
*  Read XXXXX segment using GU call                          *;
***************************************************************;

 data want;
   set have;
   length SSA1 $60.;

   database="&dbname";
   callfunc='GU  ';
   SSA1='XXXXXX(XXX0010F ='||lnno||')';

   input
    @001 lnno      $9.
    @041 groupno   $7.
    @073 lnany     pd4.6
    ;

   put '--- LNNO#  ---> ' lnno;
   put '--- GROUP# ---> ' groupno;
   put '--- ANY1#  ---> ' lnany;

   if statcode not in ( '  ', 'GE' ) then do;
     put '--- error ---> ' _all_;
     abort return 1111;
   end;
 run;

 

I am getting the values like below

 

--- LNNO#  ---> 180878298
--- GROUP# ---> F193076
--- ANY1#  ---> 0.05125

 

I am writitng these out to a dataset like below

 

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;
*   Write out warning file                                      ;
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;

data _null_;
  set want;
  file wartxn;
       put @001 srvcr    $6.
           @007 lnno     $9.
....
....
....
           @161 groupno  $7.
....
....
....
           @339 lnany    S370FZDT10.9
....
....
....       @374 slrname  $30.
           ;
run;

 

Follwoing is the output file values (in wartxn)

groupno value in a output dataset(wartxn):

----+----7-- ************ F193 760310W

The above value @161 pos, between F193 and 76 there is a space. it supposed to be F193076 for
groupno as I printed that value right after IMS db call.

 

The lenght of output file(wartxn) that I am writting out to in a jcl is different(403) than the input file(238) because I am adding some variables at the end to the file. The interesting thing is when I write the groupno anywhere beyond 238, I do not see this problem.

 

I really apprecite your time, thanks in advance.

 

Neal.


Accepted Solutions
Solution
‎08-28-2017 04:09 PM
Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost
I got it, instead of $165, it should be $165. what a bummer!

View solution in original post


All Replies
Super User
Posts: 13,889

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

 

And it may help to post text output in a codebox using the {i} instead of the run icon.

 

Since you are writing to specified columns I would very carefully double check that you do not accidently have something that is writing to the wrong column such as

put
           @161 groupno  $7.
....
           @164 othervar $1.  /*<where maybe 264 was intended*/
....
           @339 lnany    S370FZDT10.9
....
....
....       @374 slrname  $30.
Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Right, good to check and i did check, I do not have anything for column @164.

Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

Do anyone come across this kind of an issue? please let me know, i really appreciat your time.

 

Thanks,

Neal.

Super User
Posts: 8,214

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

It would help if you post your entire output statement. That would be the best way for others to spot potential overwrites.

 

Art, CEO, AnalystFinder.com

 

Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Art, please find the attached SAS output. I really appreciate your help, thanks.

Solution
‎08-28-2017 04:09 PM
Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost
I got it, instead of $165, it should be $165. what a bummer!
Super User
Posts: 8,214

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

Yes, that would do it. However, you've got additional problems as none of the following appear to be in the data you are trying to export:

 151                    @349 ppnltyof $1.
 152                    @350 intbrng  pd6.2
 153                    @356 nintbrng pd6.2
 154                    @362 crtmt    pd6.2
 155                    @368 bic      pd6.2
 156                    @374 slrname  $29.

Art, CEO, AnalystFinder.com

 

Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Thank you Art, I took care of this.

 

Neal.

Super User
Posts: 13,889

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

And an example data set that shows the same behavior. Dummy data is fine to protect any sensitive information as long as the code and the data replicate the problemn.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Contributor
Posts: 39

Re: Need help with writting out a file to a dataset

Posted in reply to saslovethemost

My apologies.. I thought zero is converting to spaces..but each character at 165 position is converting to space.I checked every where in my code if any is moving to @165 position. Dont know why..

6----+--
********
5T397 40
5U398 00
0S990 45
0S990 45
8E790 70
8B132 87
91518 20
7H356 33
8E790 70
8B132 87
7B132 87
0AQ44 87
2U000 60
2U000 60
2X341 65
2X341 65
2T397 40
2U398 00
5Q926 02
5BB28 49
5Q926 02
21518 20
51518 20
2H356 33
2H356 33
2BE35 94
2A988 50
2V528 81
1BE35 94
5A998 00
9A998 00

The actual values are like the following...

 

 

T397040
U398100
S990745
S990745
E790470
B132487
1518520
H356133
E790470
B132487
B132487
AQ44887
U000360
U000360
X341565
X341565
T397040
U398100
Q926702
BB28849
Q926702
1518520
1518520
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 262 views
  • 0 likes
  • 3 in conversation