BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Calcite | Level 5



I am attempting to export a SAS database to a space-delimited text file so that it can be imported into Mplus. I'm using SAS v9.3. Here is the code I am using:


data _null_ ; /* No SAS data set is created */
set work3mergem;
FILE 'H:\Andrewtxtbpio0501';
PUT subject anyboy anyboy2 anyboy3 anyboy4 rsksum rsksum2 rsksum3 rsksum4 age a2 schcom11--schcom16 c1g
c2g c3g c4g c5g c6g c7g c8g c9g c10g c1o c2o c3o c4o c5o c6o c7o c8o c9o c10o b9--b14 a8a ethgrp;
run ;


When I run the code, there are several asterisks in the output file instead of the values as they show in SAS (some of which are recorded values, and some of which are missing values). There are 8 asterisks in all (from a data set with 500+ observations and 1,000+ variables), and they aren't all occurring for the same variable (i.e., for one case, there's an asterisk for variable b12, for another, b14). I am having difficulty figuring out why this is happening.


The data set was originally saved in SPSS, and so the first step of my program is to import it to SAS. I'm including that code, too, in case that may somehow be part of the problem:


libname inlib spss 'H:\Research\Huebner Paper HIV\FINAL DASH DATA_ONLY GOOD CASES.por';
proc convert spss=inlib out=huebhiv.dash050118;

libname inlib spss 'H:\Research\Huebner Paper HIV\Oakland data_only good cases.por';
proc convert spss=inlib out=huebhiv.oakland050118;


Any thoughts about why this might be happening and how to address it would be greatly appreciated. Thanks!



Accepted Solutions
Opal | Level 21

A reasonable guess:  these variables have formats connected with them, that are not wide enough.  Just remove the formats:


data _null_;

set work3mergem;

format _numeric_;

FILE ........

View solution in original post

Opal | Level 21

A reasonable guess:  these variables have formats connected with them, that are not wide enough.  Just remove the formats:


data _null_;

set work3mergem;

format _numeric_;

FILE ........

Calcite | Level 5

That worked! Thank you very much. 

Diamond | Level 26 RW9
Diamond | Level 26

Without some actual data its hard to say, but I would guess that the data is formatted, and the length is not long enough to handle the format - this happens with dates for instance.  

Also how are you opening the file?  You haven't given it a file extension (.txt for instance).  Now Excel is one app that likes to show data as * which it doesn't like.  So open the file in notepadd (/++) and see what the actual output looks like.

Otherwise post some data in the form of a datastep:

So we have something to work with.



Super User Tom
Super User

That is usually an indication that the value cannot be display using the format that is attached.  For example trying to display a 5 digit number using the 4. format.  Some SAS functionality (like PROC IMPORT and SAS/Access) have a nasty habit of attaching formats to variables even when they do not need formats attached.


Check if any of the variables you are trying to write have formats attached to them. For example run a PROC CONTENTS on the dataset.


You could just try removing all of the formats using a format statement that lists variables without any format specification.  So you could just try adding this statement to your current data _null_ step.

format _all_ ;

But then if you have any variables that contain values like date, time or datetime that needs formats to display in a human readable way you will need make sure to use formats for those.  In that case add a second FORMAT statement to re-attach formats to just those variables that need them.

Calcite | Level 5

Thank you -- this was indeed the issue. I didn't have any variables that required special formatting, fortunately.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4 in conversation