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

@Reeza : I want to use this process for all type of informations :unfamiliar or familiar.

When, I give more than 500  external files -as input- I will get a sas file formats.

 

Tom
Super User Tom
Super User

If you really know nothing about the files then just run PROC IMPORT on the text files.  It will probably do as good of a job as your code could.

 

You should have enough ideas now to program your macro.  Why not take a stab at it?

Tom
Super User Tom
Super User

So once you have the data into a SAS dataset you now runs some algorithms on it to try and determine what type to use.

You can find the max length.  You can count how many missing values.  Even how many distinct values.

You can try using various INFORMATS on it to see if the value is a number or a date or a time.

 

_missing = missing(value);
_numeric = length(value)<=32 and not missing(input(value,??comma32.)) ;
_datetime = not missing(input(value,??anydtdtm.));
_date = not missing(input(value,??anydtdte.));
_time = not missing(input(value,??anydttme.));

Make up your own rules for what type to use for empty fields. Or how to handle fields where 99% is numeric but there are just a few non-numeric values.

LineMoon
Lapis Lazuli | Level 10

@Tom : please, what do mean by "Why not take a stab at it? "

Reeza
Super User

It means try to write your the desired macro. If you need further help, post what you've tried and identify where you're having issues. 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 2873 views
  • 6 likes
  • 3 in conversation