Hi ,
I am trying to export the out put text file and I am able to export the file , but one of the column (amt)results are not showing up in the output text file .. but in SAS EG output data is populating all the results , log is showing as 'NOTE: Variable amt is uninitialized in sas '
could anyone can help
data have; name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output; name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output; run; data _null_; set have nobs=num_obs end=last; file "s:\temp\rob\text.txt"; if _n_=1 then put @1 "AL16" @31 "0000"; put Name $ 1 - 17 City $ 18 - 25 Country $ 26 - 30
amt & 31 - 36 Id $ 37 - 40; tmp=strip(put(num_obs,z3.)); if last then put @1 "DL99" @31 tmp; run;
out put text file :
Thomas newjersy usa 1000
David newjersy usa 1005
* AMT 100 AND 150 ARE MISSING
Thanks
Can't be.
Running your code (only changed the filename) gave me this log:
16 data have; 17 name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output; 18 name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output; 19 run; NOTE: The data set WORK.HAVE has 2 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds 20 21 data _null_; 22 set have nobs=num_obs end=last; 23 file "$HOME/sascommunity/text.txt"; 24 if _n_=1 then put @1 "AL16" @31 "0000"; 25 put Name $ 1 - 17 26 City $ 18 - 25 27 Country $ 26 - 30 28 amt & 31 - 36 29 Id $ 37 - 40; 30 tmp=strip(put(num_obs,z3.)); 31 if last then put @1 "DL99" @31 tmp; 32 run; NOTE: The file "$HOME/sascommunity/text.txt" is: Filename=/home/xxxxxxxx/sascommunity/text.txt, Owner Name=xxxxxxxx,Group Name=yyyyyyyy, Access Permission=rw-r--r--, Last Modified=Thu Dec 15 09:02:31 2016 NOTE: 4 records were written to the file "$HOME/sascommunity/text.txt". The minimum record length was 33. The maximum record length was 40. NOTE: There were 2 observations read from the data set WORK.HAVE. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
No messages here that indicate anything went wrong.
This is the resulting file:
AL16 0000 Thomas New JersUSA 150 1000 David New JersUSA 100 1005 DL99 002
You can see that all values are present.
Include the exact output please. The answer shown doesn't align with your code.
Can't be.
Running your code (only changed the filename) gave me this log:
16 data have; 17 name="Thomas"; city="New Jersy"; country="USA";amt = 150 ;id="1000"; output; 18 name="David"; city="New Jersy"; country="USA";amt=100; id="1005"; output; 19 run; NOTE: The data set WORK.HAVE has 2 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds 20 21 data _null_; 22 set have nobs=num_obs end=last; 23 file "$HOME/sascommunity/text.txt"; 24 if _n_=1 then put @1 "AL16" @31 "0000"; 25 put Name $ 1 - 17 26 City $ 18 - 25 27 Country $ 26 - 30 28 amt & 31 - 36 29 Id $ 37 - 40; 30 tmp=strip(put(num_obs,z3.)); 31 if last then put @1 "DL99" @31 tmp; 32 run; NOTE: The file "$HOME/sascommunity/text.txt" is: Filename=/home/xxxxxxxx/sascommunity/text.txt, Owner Name=xxxxxxxx,Group Name=yyyyyyyy, Access Permission=rw-r--r--, Last Modified=Thu Dec 15 09:02:31 2016 NOTE: 4 records were written to the file "$HOME/sascommunity/text.txt". The minimum record length was 33. The maximum record length was 40. NOTE: There were 2 observations read from the data set WORK.HAVE. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
No messages here that indicate anything went wrong.
This is the resulting file:
AL16 0000 Thomas New JersUSA 150 1000 David New JersUSA 100 1005 DL99 002
You can see that all values are present.
Maybe it has to do with the use of an ampersand in the put statement.
It may not be supported by the version of SAS you're using.
What output do you obtain if you remove it ?
Solved, it is because column names are different
Thanks
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.