Note that there are some explanatory texts on larger screens.

plurals
  1. POReading Raw Data in SAS Or R
    primarykey
    data
    text
    <p>For our analysis we need to read raw data from csv (xls) &amp; convert it into SAS dataset before doing our analysis.</p> <p>Now, the problem is this raw data generally have 2 issues: 1. The ordering of columns changes sometimes. So, if in the earlier period we have columns in order of variable A,then B, then C, etc. It might change to B, then C, then A. 2. There are foreign elements like "#", or ".", or "some letters", etc. Now, we have to first clean the raw data, before reading into SAS. This take considerable amount of time. Is there any way we can clean the data within SAS system itself before reading the data. If we can rectify the data with SAS code, it will save quite amount of time. </p> <p>Here's the example:</p> <p><strong>Period 1:</strong> I got the data in Data1.csv in this format. In column B, which is numeric, I've "#" &amp; ".". And colummn C, which is also numeric, I've "g". If I import Data1.csv using either PROC IMPORT or Infile statement, these foreign elements in column B &amp; C will remain. The question here is how to do that? I can use If STATEMENT. But the problem is there are too many foreign elements (e.g. instead of "#", ".", "g", I might get other foreign elements like "$", "h" etc.) If there's any way we can have a code which detect &amp; remove foreign elements without I've to specifying it using IF STATEMENT everytime I import the raw data in SAS.</p> <pre><code> A B C Name1 1 5 Name2 2 6 Name3 3 4 Name4 # g Name5 5 3 Name6 . 6 </code></pre> <p><strong>Period 2:</strong> In this period I got DATA2.csv which is given below. When I use INFILE statement, I specify 1st A should be read with the specific name, then B with specific name &amp; then C. In 2nd period when I get the data B is given 1st. So, when SAS read the data I've B instead of A. So, I've to check the variables ordering with previous phase data everytime &amp; correct it before reading the data using infile statement. Since the number of variables are too large, it's very time consuming ( &amp; at time frustrating) to verify the column ordering in this fashion. Is there SAS code, with which SAS will automatically read A,&amp; then B &amp; then C, even though it's not in this order?</p> <pre><code>B A C 1 Name1 5 2 Name2 6 3 Name3 4 # Name4 g 5 Name5 3 . Name6 6 </code></pre> <p>Even though I mainly use SAS in my analysis purpose. But I can use R to clean the data, then use to read it in SAS for further analysis. So R code can also be helpful.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload